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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Using RANKX with Filtered Column

So I'm using the RANKX function to rank my networks by my Incentive SAIFI and it works perfect when I'm showing all networks. However when I apply a filter the rank start over. I'm want the networks to keep the same RANK. My latest DAX and example is below. 

 

 

 

Network Rank = 
var networks = ALLSELECTED(Hiearchy[Network Name])
return RANKX(ALL(networks), [Incentive SAIFI],,ASC)

 

 

 

 Raw Table

Group Network Incentive SAIFI Rank (Measure)

1A12.312
1B12.514
1C10.39
1D13.316
2E5.93
2F7.75
2G9.97
2H8.96
3I1111
3J3.91
3K12.815
3L6.74
4M5.72
4N10.810
4O10.28
4P12.413

 

Expected When Filtering Group 2

Group Network Incentive SAIFI Rank (Measure)

2E5.93
2F7.75
2G9.97
2H8.96

 

What I'm actually getting (with a previous measure, not the one above, I've been trying so many things)

Group Network Incentive SAIFI Rank (Measure)

2E5.91
2F7.72
2G9.94
2H8.93

 

Thanks in advance for the help.

 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

That didn't work for me and still the table is much bigger than I'm letting on. I don't want to just post the full raw table with company info. 

I would have loved to have gotten this working with a measure but I gave up and created a calculated table. Below was my calculated table. 

Network Rank = 
UNION(
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group1", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip)),
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group2", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip)),
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group3", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip)),
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group4", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip)),
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group5", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip))
)

 

View solution in original post

8 REPLIES 8
Greg_Deckler
Community Champion
Community Champion

How are you filtering? Via the filter panel? If so, then things are pre-filtered and inaccessible to DAX. Can you create a column for your ranking? Then it would "stick".



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Apologies, I see I didn't give enough info. If this is possible in a column, I would like for the rank to start over after each group. However when filtered on a group or subgroup, I would like for the rank to not change. I hope I was clear and thanks for your responses.

Raw Table.png

Anonymous
Not applicable

Also I am using the filter pane on group 1.

Anonymous
Not applicable

Network Rank = 
var networks = ALLSELECTED(Hiearchy[Network Name])
return RANKX(ALL(networks), [Incentive SAIFI],,ASC)

 

The DAX query above gives me this error message.

Annotation 2020-04-08 114149.png

 

@Anonymous 

 

You may try the measure below.

Measure =
RANKX (
    ALL ( Hiearchy[Group], Hiearchy[Network Name] ),
    [Incentive SAIFI],
    ,
    ASC
)

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

That didn't work for me and still the table is much bigger than I'm letting on. I don't want to just post the full raw table with company info. 

I would have loved to have gotten this working with a measure but I gave up and created a calculated table. Below was my calculated table. 

Network Rank = 
UNION(
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group1", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip)),
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group2", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip)),
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group3", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip)),
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group4", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip)),
    SUMMARIZE(CALCULATETABLE(VALUES(Hiearchy[Network Name]), Hiearchy[Group] = "Group5", Hiearchy[Network Name] <> BLANK()), Hiearchy[Network Name], "Rank", RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC,Skip))
)

 

amitchandak
Super User
Super User

@Anonymous 

Try like

Network Rank =
var networks =
return RANKX(ALLSELECTED(Hiearchy[Network Name]), [Incentive SAIFI],,ASC)

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thats exactly what I did when and the last table was my results from that.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.