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 = ADDCOLUMNS ( CALENDAR ( MIN ( fact_Sales[Date] ), MAX ( fact_Sales[Date] ) ), "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 (14)
- Power BI DAX (10)
- Power BI Query Editor (2)
- Project Management (2)
- Tabular Editor (1)