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
Anonymous
Not applicable

default slicer top N value

Hi All,

 

I have a table visual and a slicer to so select the top N value, How can i default the slicer to show top15 please?

 

Thanks 

Ammy

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Ammy,
We can do the same dynamically, so the user can select top value.
 
Please follow the following steps:
 
Create the following measure for calculating the rank:
Rank By Amount =
RANKX(ALL('Table_Name'[comp_name]), [amount],,DESC)
 
Then create a table with one column. (You can use Enter Data option in Power BI)
For ex use the name Top for both table name and column name.
Insert values like 10, 20, 30, ....  200.
Use this table values for filtering dynamically.
 
Then create the second measure:
Selected Top N Value = SELECTEDVALUE('Top'[Top])
 
Then create one more measure measure:
comp_name Included = IF([Rank By Amount] <= [Selected Top N Value],1,0)
And add this measure in Filters pane and set the value equal to 1.
 
Please refer the following image for reference.
Capture.PNG

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi Ammy,
We can do the same dynamically, so the user can select top value.
 
Please follow the following steps:
 
Create the following measure for calculating the rank:
Rank By Amount =
RANKX(ALL('Table_Name'[comp_name]), [amount],,DESC)
 
Then create a table with one column. (You can use Enter Data option in Power BI)
For ex use the name Top for both table name and column name.
Insert values like 10, 20, 30, ....  200.
Use this table values for filtering dynamically.
 
Then create the second measure:
Selected Top N Value = SELECTEDVALUE('Top'[Top])
 
Then create one more measure measure:
comp_name Included = IF([Rank By Amount] <= [Selected Top N Value],1,0)
And add this measure in Filters pane and set the value equal to 1.
 
Please refer the following image for reference.
Capture.PNG
Anonymous
Not applicable

Hi

In this exmple is it deafulting to top 10 ? Thanks 

 

Anonymous
Not applicable

You can add one more measure for default value.

Selected Top N Value New = IF(HASONEVALUE('Top'[Top]), SELECTEDVALUE('Top'[Top]), MIN('Top'[Top]))
Also update the previous measure
comp_name Included = IF([Rank By Amount] <= [Selected Top N Value New],1,0)
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

To show a slicer with top N, you need to create a Rank Measure like the example below.

Rank Brand = 
RANKX(
    CALCULATETABLE(
        VALUES( 'Product'[Brand] ), 
        ALLSELECTED()
    ), 
    CALCULATE(
        SUMX(Sales, Sales[Net Price] * Sales[Quantity])
    ),, 
    DESC
) 

and use it as a Visual filter as below
image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

Anonymous
Not applicable

Hi 

 

Thanks for your help.

 

In this case if i use visual filter for the slicer and restict it by setting the  "is less than or equal to" = 15, 

then the slicer does not allow me to go more than rank 15 , i have upto 200 rank, which the user will also want to see.

Just deafulting it to the top 15 in the table visual. Please suggest how to achive that.

 

Thanks  

Hi @Anonymous 

 

Can you share some data sample and explain your scenario based on that.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.



Anonymous
Not applicable

i have rank morethan 200, i just got untill 27 as sample ,

comp_nameamountrank
 Customer Requested91,9871
 Listing Miscellaneous Outright - 201134,5672
White Pages33,9853
 Print Credit - 201229,0004
White Pages Customised 201212,3455
Reversal On Answer16
Horn Loud Speaker17
Disabilities18
Disabilities -drf19
dggfs11,34510
T-Hub 2  hkjeckns11,30511
T-Hub 2 admint10,30512
T-Hub 2  separate10,00013
T-Hub 2  hkjeckns29,30514
T-Hub 2  hkjeckns49,20515
T-Hub 2  hkjeckns78,68816
T-Hub 2  hkjeckns88,54317
T-Hub 2  hkjeckns97,65418
T-Hub 2  hkjeckns07,43219
T-Hub 2  hkjeckns37,32120
T-Hub 2  hkjeckns17,16721
T-Hub 2  solumna 345,99922
T-Hub 2  solumna 355,98723
T-Hub 2  solumna 365,90024
T-Hub 2  solumna 374,56725
T-Hub 2  solumna 383,72426
T-Hub 2  solumna 3962527

 

in the report i want the slicer value to default to top 15, but user can still slide the slicer and chnge it to more than 15 or less than 15,

 
 
 

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.