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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
bdog1971
Regular Visitor

Filter Ranking Table based off Slicer

I am a beginner to PowerBi and I need to filter my table by the Ranking column to only show the top 5 records, top 10 records, top 15 records, bottom 5 records, bottom 10 record.    Table Below.  

 

Thanks

 

RankingProjectTypeRiskThreats 
1Project 1GovernanceSignificantMajor
2Project 2ProjectSignificantMajor
3Project 3GovernanceSignificantMajor
4Project 4ProjectSignificantMajor
5Project 5ProjectMajorMajor
6Project 6GovernanceSignificantMajor
7Project 7ProjectSignificantMajor
8Project 8ProjectMajorMajor
9Project 9ProjectModerate Major
10Project 10ProjectMajorMajor
11Project 11ProjectMajorMajor
12Project 12ProjectSignificantMajor
13Project 13ProjectSignificantMajor
14Project 14ProjectSignificantMajor
15Project 15ConsultingMajorMajor
16Project 16ProjectMajorMajor
17Project 17ProjectMajorMajor
18Project 18GovernanceMajorMajor
19Project 19ConsultingMajorMajor
20Project 20ProjectMajorMajor
21Project 21ProjectUnspecifiedMajor
22Project 22ProjectModerate Moderate
23Project 23ProjectUnspecifiedMajor
24Project 24ProjectMajorMajor
25Project 25ConsultingModerate Moderate
26Project 26ConsultingMinorModerate
27Project 27ProjectModerate Major
28Project 28ConsultingModerate Moderate
29Project 29ConsultingUnspecifiedMajor
30Project 30GovernanceUnspecifiedMajor
31Project 31ConsultingUnspecifiedMajor
32Project 32ConsultingMajorMajor
33Project 33ProjectUnspecifiedMajor

 

 

1 ACCEPTED SOLUTION

@bdog1971  you can use this

Measure =
VAR _AscendingOrder =
    RANKX ( ALLSELECTED ( t1 ), CALCULATE ( MAX ( t1[Ranking] ) ),, ASC )
VAR _DescendingOrder =
    RANKX ( ALLSELECTED ( t1 ), CALCULATE ( MAX ( t1[Ranking] ) ),, desc )
VAR _selection =
    SWITCH (
        TRUE (),
        CONTAINSSTRING ( SELECTEDVALUE ( 'New-Slicer'[Category] ), "Bottom" ), _AscendingOrder,
        _DescendingOrder
    )
VAR _value =
    IF ( _selection <= SELECTEDVALUE ( 'New-Slicer'[Value] ), _selection )
VAR _select =
    SELECTEDVALUE ( 'New-Slicer'[Category] )
RETURN
    IF ( _select = BLANK (), MAX ( t1[Ranking] ), _value )

 

smpa01_0-1637639205421.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

See if the link here helps - Vendor Analysis In Inventory Management Dashboards.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

I would say there are several ways to get desired output, but based on the question I'm not sure if you want many tables, visual or other output. Just by loading your table to PBI you can use the ranking in a slicer:

Krib_0-1637615408234.png

or as a filter in the filter pane:

Krib_1-1637615528215.png

or to the table it's self as  a "TOP N" using TOP/BOTTOM:

Krib_2-1637615737638.pngKrib_3-1637615765884.png

 

 

The top one would be the best for what I am doing.    I was trying not to hard code the values but let the reader of the report be able to select what they wanted.  

smpa01
Super User
Super User

@bdog1971  you can use a measure like this

Measure = 
VAR _AscendingOrder = RANKX(ALLSELECTED(t1),calculate(MAX(t1[Ranking])),,ASC)
VAR _DescendingOrder = RANKX(ALLSELECTED(t1),calculate(MAX(t1[Ranking])),,desc)
VAR _selection =
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( 'New-Slicer'[Category] ) = "Bottom10"
            || SELECTEDVALUE ( 'New-Slicer'[Category] ) = "Bottom20"
            || SELECTEDVALUE ( 'New-Slicer'[Category] ) = "Bottom5", _AscendingOrder,
        _DescendingOrder
    )
VAR _value =
    IF ( _selection <= SELECTEDVALUE ( 'New-Slicer'[Value] ), _selection )
RETURN
    _value

pbix is attached

smpa01_0-1637615108399.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

What do I need to add so when nothing is selected in the slicer that is shows me all the records instead of no records?  Sorry I shuold have added that in my explanation?

 

Thank you so much for the help.  

@bdog1971  you can use this

Measure =
VAR _AscendingOrder =
    RANKX ( ALLSELECTED ( t1 ), CALCULATE ( MAX ( t1[Ranking] ) ),, ASC )
VAR _DescendingOrder =
    RANKX ( ALLSELECTED ( t1 ), CALCULATE ( MAX ( t1[Ranking] ) ),, desc )
VAR _selection =
    SWITCH (
        TRUE (),
        CONTAINSSTRING ( SELECTEDVALUE ( 'New-Slicer'[Category] ), "Bottom" ), _AscendingOrder,
        _DescendingOrder
    )
VAR _value =
    IF ( _selection <= SELECTEDVALUE ( 'New-Slicer'[Value] ), _selection )
VAR _select =
    SELECTEDVALUE ( 'New-Slicer'[Category] )
RETURN
    IF ( _select = BLANK (), MAX ( t1[Ranking] ), _value )

 

smpa01_0-1637639205421.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Ok still having one issue but can not seem to find it in your file.  Then I select "Top5" is does not remove the other records like yours does.    As seen in the below image.  Yours takes away all the records.   I see there is a Ranking fileter on yours when I mouse over it but not sure how to get that or where to set it.  Thanks

 

bdog1971_0-1637700443906.png

bdog1971_1-1637700520331.png

 

@bdog1971  can you please post the pbix?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Here you go. 

Test V2.pbix 

Looks good. I'd suggest not hard-coding the specific category values though.

VAR _selection =
    IF (
        CONTAINSSTRING ( SELECTEDVALUE ( 'New-Slicer'[Category] ), "Bottom" ),
        _AscendingOrder,
        _DescendingOrder
    )

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.