Skip to content

Instantly share code, notes, and snippets.

@biliboss
Created June 18, 2021 22:08
Show Gist options
  • Save biliboss/7c2baf793a16373c8eabec9a8c9c6a97 to your computer and use it in GitHub Desktop.
Save biliboss/7c2baf793a16373c8eabec9a8c9c6a97 to your computer and use it in GitHub Desktop.
Power BI | DAX Date Table
_Date =
VAR BaseCalendar = CALENDARAUTO()
RETURN
GENERATE (
BaseCalendar,
VAR BaseDate = [Date]
VAR DayNumber = Right(CONCATENATE("00",DAY ( BaseDate )),2)
VAR YearDate = YEAR ( BaseDate )
VAR MonthNumber = Right(CONCATENATE("00",MONTH ( BaseDate )),2)
VAR JoinDate = CONCATENATE(01,CONCATENATE("/",CONCATENATE(MonthNumber,CONCATENATE("/",2018))))
VAR MonthName = FORMAT ( BaseDate, "mmm")
VAR MonthFullName = FORMAT ( BaseDate, "mmmm")
VAR YearMonthName = FORMAT ( BaseDate, "yyyymmmm" )
VAR YearMonthNumber = YearDate * 12 + MonthNumber - 1
VAR Aging = TODAY() - BaseDate
RETURN ROW (
"Join Date",JoinDate,
"Day", DayNumber,
"Year", YearDate,
"Month Number", MonthNumber,
"Month", MonthName,
"Month Full", MonthFullName,
"Year Month Number", YearMonthNumber,
"Year Month", YearMonthName,
"Aging", Aging
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment