Рет қаралды 20,885
Calculate Sales This week and Last Week using a Button in PowerBI | MI Tutorials
Watch the Tutorial to know How to Create a Calendar Table: • How to Create Calendar...
Code to Create Calendar:
Calendar =
VAR MinDate = MIN('50000 Sales Records'[Order Date])
Var MaxDate = Max('50000 Sales Records'[Order Date])
VAR Days = CALENDAR ( MinDate, MaxDate )
RETURN ADDCOLUMNS (
Days,
"Year", YEAR ( [Date] ),
"Month Number", MONTH ( [Date] ),
"Month", FORMAT ( [Date], "mmmm" ),
"Year Month Number", YEAR ( [Date] ) * 12 + MONTH ( [Date] ) - 1,
"Year Month", FORMAT ( [Date], "mmm yy" ),
"Week Number", WEEKNUM ( [Date] ),
"Week Number and Year", "W" & WEEKNUM ( [Date] ) & " " & YEAR ( [Date] ),
"WeekYearNumber", YEAR ( [Date] ) & 100 + WEEKNUM ( [Date] )
)