2. On the Home ribbon tab, from inside the Calculations group, click New Table.
3. In the formula bar, enter the following, and then press Enter:
Date =
CALENDARAUTO(6)
or you may want to use the CALENDAR function. like
DATE = CALENDAR (DATE (2020,07,01), DATE (2025,06,30))
At the bottom-left corner, in the status bar, notice the table statistics, confirming that 1826 rows of data have been generated, which represents five full years’ data.
5. Create the following two calculated columns for the Date table:
- Quarter
- Month
Quarter =
‘Date'[Year] & ” Q”
& IF(
MONTH(‘DATE'[DATE]) <= 3,
3
IF(
MONTH(‘DATE'[DATE]) <= 6,
4
IF(
MONTH(‘DATE'[DATE]) <= 9,
1,
2
)
)
)
Month =
FORMAT(‘Date'[Date], “yyyy MMM”)
By default, text values sort alphabetically, numbers sort from smallest to largest, and dates sort from earliest to latest.
6. Add the MonthKey column to the Date table. This formula computes a numeric value for each year/month combination.
MonthKey = (YEAR(‘Date'[Date]) * 100) + MONTH(‘Date'[Date])
Ref: Lab – Introduction to DAX in Power BI Desktop – Learn | Microsoft Docs