Forum Discussion
JackWren
Helper II
4 years agoCreate ranking based on specific value (current month)
Hi,
I have a dax calendar with the following elements :
Dax Calendar =
ADDCOLUMNS (
CALENDAR (DATE(YEAR(TODAY())-1,1,1), DATE(YEAR(TODAY()),12,31)),
"YEAR", YEAR ( [Date] ),
"YearMonthShort", FORMAT ( [Date], "YYYY-mmm" ),
"MonthNameLong", FORMAT ([Date], "mmmm" ),
"MonthNumber", month([Date]),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" )
)
And I would like to add a month ID column that would give me a relative ranking based on the current month (current month is 0).
I know how to use rank but not with a specific value as a start.
| 2021-11 | -4 |
| 2021-12 | -3 |
| 2022-01 | -2 |
| 2022-02 | -1 |
| 2022-03 | 0 |
| 2022-04 | 1 |
| 2022-05 | 2 |
Thank you
Have a nice day
Jack
add a new column to your calendar definition
"Ranking",
var yearMonInt = INT( FORMAT( [Date], "YYYYMM"))
var todayInt = INT( FORMAT( TODAY(), "YYYYMM"))
return yearMonInt - todayInt