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
TSki
Regular Visitor

Top N slicer using measure

I am trying to make a sliding slicer off of this measure. I found this code from another user that, gives the TOPN for using COUNTROW to get the TOPN of the most repeated values. 

Measure =
VAR __topn =
    TOPN (
        5,
        VALUES ( Table[Category Level 1] ),
        RANKX ( ALL ( Table[Category Level 1] ), COUNTROWS ( Table ),, ASC )
    )
RETURN
    CALCULATE ( COUNTROWS ( Table ), __topn )


My is slicer is called "TOPN" and it can be slid from 0-20, where the number it is on should be the number of top values shown.

 

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @TSki ,

 

Unfortunately, you can't add measure to slicer. As an alternative, you can create a new column:

 

TOPN = RANKX('Table',[The most repeated values],,DESC,Dense)

 

vyadongfmsft_0-1666577616547.png

 

I think this is pretty close to what you want:

vyadongfmsft_3-1666580663318.png

 

vyadongfmsft_2-1666580615171.png

Or like this:

vyadongfmsft_1-1666577642931.png

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yadongf-msft
Community Support
Community Support

Hi @TSki ,

 

Unfortunately, you can't add measure to slicer. As an alternative, you can create a new column:

 

TOPN = RANKX('Table',[The most repeated values],,DESC,Dense)

 

vyadongfmsft_0-1666577616547.png

 

I think this is pretty close to what you want:

vyadongfmsft_3-1666580663318.png

 

vyadongfmsft_2-1666580615171.png

Or like this:

vyadongfmsft_1-1666577642931.png

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yadongf-msft
Community Support
Community Support

Hi @TSki ,

 

Do you want to count the number of the most most repeated values and then use it as slicer? If so, please try following steps.

 

This is my test table:

vyadongfmsft_0-1666058557665.png

 

Create a new column instead of a measure:

 

The most repeated values = CALCULATE(COUNT('Table'[Category Level 1]),FILTER('Table','Table'[Category Level 1] = EARLIER('Table'[Category Level 1])))

 

vyadongfmsft_1-1666058609814.png

 

Create a slicer using the column just created:

vyadongfmsft_2-1666058683650.png

If I misunderstand your demands, please feel free to contact us in time.

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for your reply @v-yadongf-msft , 

With this new column, can I apply a TOPN measure to it and then apply to a slicer? Where a one on the slicer displays the most repeated value, 2 shows the top 2 most repeated values, and so on. So in your test data, when the slicer is slid to 1: B will be displayed and when slid 2: B and D are displayed, when on 3: B, D, E, A are displayed and on 4: B, D, E, A, C are displayed. 

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.