cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kiran1407
New Member

Ranking Logic not working as expected when filters are applied

Hi Everyone,

Am a newbie to PowerBI. I came across a scenario where my "Ranking" Column is not working as expected in my original dashboard. I tried to recreate the same scenario with some dummy data as shown in the snippets.

Snippet 1: Base table "Table" showing the data for certain fields, Country, City, Place, Cat Type and Continent.

Kiran1407_3-1684427827200.png

 

 

Snippet 2:  New Table "Slicer Table" - created using UNION of selected columns from Base Table - "Table".

Kiran1407_2-1684427795051.png

 

Kiran1407_6-1684429968558.png

 

* Logic for Value(Dynamic) - Measure in Table is:

Value (Dynamic) =
VAR CategorySelection = SELECTEDVALUE(SlicerTable[Selection], "City")
RETURN
SWITCH(
    TRUE(),
    CategorySelection = "Country", CALCULATE(sum('Table'[Value]), TREATAS(VALUES(SlicerTable[Category]), 'Table'[Country])),
    CategorySelection = "City", CALCULATE(sum('Table'[Value]), TREATAS(VALUES(SlicerTable[Category]), 'Table'[City])),
    CategorySelection = "Place", CALCULATE(sum('Table'[Value]), TREATAS(VALUES(SlicerTable[Category]), 'Table'[Place]))
   
)



*Logic for Ranking - Calculated Column in Slicer Table is:

Ranking =
VAR CurrentSelection = SlicerTable[Selection]
RETURN
RANKX(
    FILTER(SlicerTable, SlicerTable[Selection] = CurrentSelection),
    SlicerTable[Total],,DESC
)

- Merged 3 different categories (City, County and Place) to act as a single Slicer and rows for Category Column changes as per the choice in selection slicer. Now when i tried to keep filters (continent,Cat Type) from "Table" to this page - my ranking logic is not working as expected in my original report where as its working fine in the below snippet with dummy data.

 

Kiran1407_5-1684429170837.png

 

My Objective: Ranking logic should work as expected and provide the consistent descending order, even if we select any filters from "Table" on the above Graph. 
In my original file, i used  Ranking with descending order, the values will be consistent for few rows and the sequence gets messed up in between. Can anyone please help me out?

 

 

 

0 REPLIES 0

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors