Last active
March 7, 2024 12:49
-
-
Save OscarValerock/911cd58b4d1a019c0f6944b4bfd58842 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This gist containt useful pieces of DAX code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date Table = | |
VAR MinYear = YEAR ( MIN ( 'Table Name'[Table Column] ) ) | |
VAR MaxYear = YEAR ( MAX ( 'Table Name'[Table Column] ) ) | |
RETURN | |
ADDCOLUMNS ( | |
FILTER( | |
CALENDARAUTO( ), | |
AND( | |
YEAR([Date])>=MinYear, | |
YEAR([Date])<=MaxYear | |
) | |
), | |
"Year", YEAR ( [Date] ), | |
"Month Number", MONTH ( [Date] ), | |
"Year-Month",YEAR([Date])&"-"&if(LEN(MONTH([Date]))=1,"0"&MONTH([Date]),MONTH([Date])), | |
"YY-MM", FORMAT([Date], "YY-MM"), | |
"YYMM", FORMAT([Date], "YYMM"), | |
"Weekday", FORMAT ( [Date], "dddd" ), | |
"Weekday number", WEEKDAY( [Date] ), | |
"Year-Quarter",Year([Date])& " Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1, | |
"FY-YY", IF(MONTH([Date])>=7, "FY-"&RIGHT(YEAR([Date]) + 1,2) , "FY-"&RIGHT(YEAR([Date]),2)), | |
"FYYYY",IF(MONTH([Date])>=7, YEAR([Date]) + 1,YEAR([Date])), | |
"After Today", IF([Date] > TODAY(), TRUE(), FALSE()) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rolling sum = | |
VAR MaxDate = MAX('Date Table'[Date]) | |
RETURN | |
CALCULATE( | |
[Measure], | |
'Date Table'[Date] <= MaxDate, | |
ALL('Date Table') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment