Skip to content

Instantly share code, notes, and snippets.

@stuarthallows
Last active November 25, 2018 00:11
Show Gist options
  • Save stuarthallows/9bdcab41489febcda5d3ca1779927d67 to your computer and use it in GitHub Desktop.
Save stuarthallows/9bdcab41489febcda5d3ca1779927d67 to your computer and use it in GitHub Desktop.
DAX to generate a date table for all dates in the model
Dates =
VAR BaseCalendar = CALENDARAUTO()
RETURN
GENERATE (
BaseCalendar,
VAR BaseDate = [Date]
RETURN ROW (
"Year", YEAR(BaseDate),
"Quarter", INT(FORMAT(BaseDate, "q")),
"Month", MONTH(BaseDate),
"Day", DAY(BaseDate),
"MonthShortName", FORMAT(BaseDate, "MMM"),
"MonthFullName", FORMAT(BaseDate, "MMMM"),
"Year Month", FORMAT(BaseDate, "MMM yy")
)
)
@stuarthallows
Copy link
Author

Taken from the sqlbi blog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment