Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JackWren
Helper II
Helper II

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

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

add a new column to your calendar definition

"Ranking", 
var yearMonInt = INT( FORMAT( [Date], "YYYYMM"))
var todayInt = INT( FORMAT( TODAY(), "YYYYMM"))
return yearMonInt - todayInt

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

add a new column to your calendar definition

"Ranking", 
var yearMonInt = INT( FORMAT( [Date], "YYYYMM"))
var todayInt = INT( FORMAT( TODAY(), "YYYYMM"))
return yearMonInt - todayInt

Thank you so much! It definitely does the job 🙂 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.