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
aktripathi2506
Helper IV
Helper IV

Ranking function not working with slicer

I have these three columns in my table.

Now I want to show top 5 based on the maximum hours.

 

I have applied following formula

RANKX(ALLSELECTED('Table'[Name]),CALCULATE(SUM('Table'[Hours])))

 

But I have a year slicer too, when I apply the slicer this rank go off…

 

Meaning this is ranking all despite of slicer, so when I select for example 2015 then rank could be 1,2,3,6 (4,5 missing i.e. rank number in between are missing)

Am I doing any logical mistake here, please advice

 

 

This is not the real data, this is just for understanding.

 

NameHoursyear
A132015
B452015
C232015
D122015
E342015
F232015
G652015
H342015
I322015
A232016
B242016
C542016
D342016
E642016
F312016
G122016
H182016
I382016
1 REPLY 1
MattAllington
Community Champion
Community Champion

I suggest you extend your data model into a star schema.  Read my article here http://exceleratorbi.com.au/the-optimal-shape-for-power-pivot-data/

 

Then create a Year table and a Name table. and put the columns from those table in your visual. 

 

then write this formula

RANKX(ALL(NameTable),CALCULATE(SUM('Table'[Hours])))


Alternatively you could just use this,

RANKX(ALLEXCEPT('Table','Table'[Year]),CALCULATE(SUM('Table'[Hours])))

 

 

but that would miss a learning opportunity 🙂

 

 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

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!

November Carousel

Fabric Community Update - November 2024

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

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.