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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nbrandborg
Helper II
Helper II

Rank rolling 12 months from 1-12 in chronological order

Hi all

 

I have a dataset containing data from the last 12 months. I would need to compare the earliest month with the latest month. The months will change everytime the dataset is update every month. So I thought it would be best with a supporting column that ranked the months from 1-12 depending on the chronological order. Then I could alway compare month 1 with month 12. This is a snippet of what I want to achieve. I have the first column which is dynamic and I would like to have the second column.

July 20211
August 20212
September 20213
October 20214
November 20215
December 20216
January 20227
February 20228
March 20229
April 202210
May 202211
June 202212


Best regards!

1 ACCEPTED SOLUTION
nbrandborg
Helper II
Helper II

I found that I had Year and MonthNumber as seperate columns in the dataset. I had to convert the MonthNumber from 1,2,3,4... to 01, 02, 03, 04.... and then concatenate that with the Year. Then I had the column 202107, 202108, 202109, 202110.....
Becuase I had dublicates, so more rows with 202110 for example I used a dense RANKX, which solved it 🙂

View solution in original post

3 REPLIES 3
nbrandborg
Helper II
Helper II

I found that I had Year and MonthNumber as seperate columns in the dataset. I had to convert the MonthNumber from 1,2,3,4... to 01, 02, 03, 04.... and then concatenate that with the Year. Then I had the column 202107, 202108, 202109, 202110.....
Becuase I had dublicates, so more rows with 202110 for example I used a dense RANKX, which solved it 🙂

@nbrandborg exactly right. In your example you had one row per month and that is why I said "then a simple rank.eq function as a calculated column will suffice" but when this is not the case, then you need the good friend RANKX 🙂

Please don't forget to accept my previous message as a solution for community visibility.
P.S. Check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. Please give it a thumbs up over there if you liked it 🙂
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543


SpartaBI
Community Champion
Community Champion

@nbrandborg if you will have a numerical column that represnt these months (now they look like text) then a simple rank.eq function as a calculated column will suffice. It will update everytime with the correct numbers from 1 to 12.
But you need to add before a column like:

Month Year Sorting
202105
202106
.
.

And then you could rank by that



2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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