DAX for a calendar table
- February 24, 2020
- Marnix Jansen
- Power BI DAX
Most Power BI models require a date table. Just add a new table to your model and copy-paste this code to get one.
Here it is:
dim_Calendar = // replace these values for the ones in your datamodel VAR _Startdate = MIN ( Sales[Date] ) VAR _Enddate = MAX ( Sales[Date] ) RETURN ADDCOLUMNS ( CALENDAR ( _Startdate, _Enddate ), "Month" , MONTH ( [Date] ), "MonthName" , FORMAT ( [Date] , "mmmm" ), "Year" , YEAR ( [Date] ), "Quarter" , "Q" & QUARTER ( [Date] ), "YearMonth" , YEAR ( [Date] ) * 100 + MONTH ( [Date] ), "Day" , DAY ( [Date] ) )
Categories
- Excel (1)
- Power Apps (2)
- Power BI (18)
- Power BI DAX (10)
- Power BI Query Editor (2)
- Project Management (2)
- Tabular Editor (1)
Recent Posts
-
You have completed your Power BI report,
Jun 28, 2023
When you start a new reportJun 28, 2023
Soft skills are more important than hard onesJun 28, 2023
Combine multiple Excel sheetsMay 05, 2023