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
Dharini
Frequent Visitor

Dynamic ranking a column based on slicer created from master table

Hi All,

 

I have a slicer called Region(from master table - Region) which has relation to Region field in Test table.

Region
Test1
Test2
Test3
Test4

 

I have to dynamically rank  the Test table based on value column depending on slicer selection - Region. I have data for test table as given below.

Region ProjectIdValue
Test1123
Test1234
Test2353
Test349
Test4517
Test4617

 

If Test1 is selected in Region slicer, then it should be displayed as below,

Region ProjectIdValueRank
Test11232
Test12341

 

If Test 2 and Test 3 is selected in Region slicer,then it should be displayed as below ,

region ProjectIdValueRank
Test23531
Test3492

 

If Test 2 and Test 4 is selected, then it should be displayed as below,

Region ProjectIdValueRank
Test23531
Test45172
Test4617

2

 

If All is selected in slicer,then it should be displayed as ,

 

Region ProjectIdValueRank
Test11233
Test12342
Test23531
Test3495
Test45174
Test46174

 

i have created a rank measure as 

Rank = RANKX(ALLSELECTED('Test'),CALCULATE(SUM('Test'[Value]),ALLEXCEPT('Test',Region[REGION],'Test'[ProjectId])),,DESC,Dense).

 

This works fine when region slicer is created from test table.

But i wanted to dynamically rank the value column based on selection from region slicer(master).

 

Kindly do help.

 

Thanks

Dharini

 

1 ACCEPTED SOLUTION

Hello @Dharini

 

I can suggest you build the below simple model:

 

2018-11-21_12-28-49.jpg

 

 

Then this measure should do what you want. When you add the items to the table visual for Region, ProjectID and Value, choose do not summarize for all of them. Also notice that on the rows section of the table, Ive dropped the column of the dimension tables (projects, regions)

 

Ranking = 
IF(
    COUNTROWS( Data ) > 0,
    RANKX(
        CALCULATETABLE(
            SUMMARIZE( Data, Projects[ProjectId], Regions[Region ] ),
            ALLSELECTED()
        ),
        CALCULATE( MAX( Data[Value] ), ALLEXCEPT( Data, Regions[Region ], Projects[ProjectId] ) ),,DESC,Dense
    )
)

2018-11-21_12-31-30.jpg2018-11-21_12-31-05.jpg2018-11-21_12-30-42.jpg

 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

5 REPLIES 5
PattemManohar
Community Champion
Community Champion

@Dharini Please try this as a "New Measure"

 

Test144 = RANKX(ALLEXCEPT(Test144DynamicRnk,Test144DynamicRnk[Region ]),CALCULATE(MAX(Test144DynamicRnk[Value]),ALLSELECTED(Test144DynamicRnk[Region ])),,DESC,Dense)

image.pngimage.pngimage.pngimage.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




@PattemManohar  Thanks for your quick reply.

 

This measure works fine when region slicer is created is created from Test table .

 

But when Region slicer is created from master table Region, Data is not filtered as given below in Test table

 

When Test1 is selected from region slicer, below data is displayed

Region ProjectIdValueRank
Test11233
Test12342

 

 When Test1 and Test4 is selected in Region slicer , below data is displayed

Region ProjectIdValueRank
Test11233
Test12342
Test45174
Test46174

Hello @Dharini

 

I can suggest you build the below simple model:

 

2018-11-21_12-28-49.jpg

 

 

Then this measure should do what you want. When you add the items to the table visual for Region, ProjectID and Value, choose do not summarize for all of them. Also notice that on the rows section of the table, Ive dropped the column of the dimension tables (projects, regions)

 

Ranking = 
IF(
    COUNTROWS( Data ) > 0,
    RANKX(
        CALCULATETABLE(
            SUMMARIZE( Data, Projects[ProjectId], Regions[Region ] ),
            ALLSELECTED()
        ),
        CALCULATE( MAX( Data[Value] ), ALLEXCEPT( Data, Regions[Region ], Projects[ProjectId] ) ),,DESC,Dense
    )
)

2018-11-21_12-31-30.jpg2018-11-21_12-31-05.jpg2018-11-21_12-30-42.jpg

 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Thankyou @LivioLanzo It works fine 🙂

Anonymous
Not applicable

HI- 

This is a very good video to help explain RankX 

 

RankX Video

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.