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

Dynamic Top N values with threshold slicer

I have a project where I am trying to dynamically show bottom 3 or bottom 5 changes in YoY sales based on a slicer selected. I am also trying too create a slicer that filters for a threshold number of products sold (100, 250, 500). I would like the ranking to follow my threshold slicer so each time I select a new one the bottom 3 or 5 is refreshed to show the largest decrease in sales with a certain number of products sold. 

 

Rank = IF(SUM(Table1[Products Sold]) > SELECTEDVALUE('Product Threshold'[Product Threshold]), RANKX(ALLSELECTED(Table1[Store Name]), SUM(Table1[YoY Sales Change]),,ASC),BLANK())

Capture2.JPG

 

Capture.JPG

 

Not sure if this is possible since I just started using Power BI.

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@ZakMeyer,

 

You may refer to the DAX below.

Rank =
IF (
    SUM ( Table1[Products Sold] )
        >= SELECTEDVALUE ( 'Product Threshold'[Product Threshold] ),
    RANKX (
        FILTER (
            ALLSELECTED ( Table1[Store Name] ),
            CALCULATE (
                SUM ( Table1[Products Sold] )
                    >= SELECTEDVALUE ( 'Product Threshold'[Product Threshold] )
            )
        ),
        CALCULATE ( SUM ( Table1[YoY Sales Change] ) ),
        ,
        ASC
    ),
    BLANK ()
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-chuncz-msft

 

You code worked to identify which stores are above the threshold of products sold but ranked them all as 1. 

 

I also realized I left out some details and code that may be helpful.

 

First is the stores are already regionally filtered so the view I showed is one region. Second is the code below.

 

These two lines of code determine if value shows making the 3 or 5 with a 1 thenputting a visaul filter of "Should Store be Included is 1" on the table.

SelectedTopNNumber = MIN('TopN'[Top])

Should Store Be Included = IF([Rank]<= [SelectedTopNNumber],1,0)

This code is how YoY Sales change is calculated

YoY Sales Change = DIVIDE(SUM(Table1[cur_Products Sold), SUM(Table1[Products Sold_12]),1)-1

Hopefully that helps give some more context and thank you for you help so far.

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.