Forum Discussion

JackWren's avatar
JackWren
Icon for Helper II rankHelper II
4 years ago
Solved

Create 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-030
2022-041
2022-052

 

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

2 Replies

  • add a new column to your calendar definition

    "Ranking", 
    var yearMonInt = INT( FORMAT( [Date], "YYYYMM"))
    var todayInt = INT( FORMAT( TODAY(), "YYYYMM"))
    return yearMonInt - todayInt
    • JackWren's avatar
      JackWren
      Icon for Helper II rankHelper II

      Thank you so much! It definitely does the job 🙂