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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
joshcomputer1
Helper V
Helper V

Rank on item and Month Number

 

I have a dataset that has Month number, CINUM, and a Count. I want to rank the CINUM's by count by month. So if Utilive has the highest count, then it is ranked 1 for that month. Each month, the count starts over.  I would like this to be done in a calculated column if possible.  If not, a measure will work. 

 

ss1.PNG

10 REPLIES 10
Greg_Deckler
Super User
Super User

Column = RANKX(FILTER(ALL('Table'),[Month]=EARLIER([Month])),[Count])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

CINUM Rank = rankx(filter(all('CI Grouped'),[Month]= earlier([Month])),[Sum Count])

 

I get the error : earlier refers to an earlier row context which doesn't exist. 

Hi @joshcomputer1,

 

What is [Sum Count]? Measure or calculated column?

 

In addition, could you please share your desired output so that we could understand your requirement better and get the solution?

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sum count is a measure.  The desired output is another column that has the rank of the CINUM SCRUB for that month. 

Hi @joshcomputer1,

 

Is the image in your first post the original data?

 

Could you please share your expected output look like?

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The rank column is what we are trying to solve. It is the rank based on the count of that CINUM for the month. 

 

ss1.PNG

@joshcomputer1 I just did what @Greg_Deckler provided and it worked fine. Are you adding rank as  column not measure? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I got the earlier error  listed above when adding rankx in the data view as a calc'ed column. I would prefer a column.  When I tried this was rankx as a measure, I do not get an error, but all CINUM SCRUBs are a value of 1. 

@joshcomputer1share your DAX expression  you are using to add rank.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Cinum rank =rank(filter(all('ci grouped'), [month]=earlier([month])),'ci grouped'[count])

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.