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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
FarsH
New Member

How to Identify top Performing based on selected parameter

hi, I'm working on a report and I want to give flexibilty to the user such that each time the
user select a certain product from the slicer "Products", and chooses a desired parameter from the "Metrics Value",
he's going to have cards of top/bottom (country, buyertype, month and day) based on his selection.

I've tried effort and found that parameters can't be included in DAX measures, hence,
I've resolved to using if statement below to control my selection,

 

TopT = IF(
    SELECTEDVALUE('Values'[Product SlicerP Order]) = 0,
    RANKX(ALLSELECTED('Mediterranean Cameras Company'[Product]), [Net Sales],,DESC) <= 1,

    IF(
    SELECTEDVALUE('Values'[Product SlicerP Order]) = 1,
    RANKX(ALLSELECTED('Mediterranean Cameras Company'[Product]), [Net Profit],,DESC) <= 1,

    IF(
    SELECTEDVALUE('Values'[Product SlicerP Fields]) = 2,
    RANKX(ALLSELECTED('Mediterranean Cameras Company'[Product]), [Net Profit Margin],,DESC) <= 1,

    IF(
    SELECTEDVALUE('Values'[Product SlicerP Fields]) = 3,
    RANKX(ALLSELECTED('Mediterranean Cameras Company'[Product]), [Total Unit Sold],,DESC) <= 1))))

 


but its yielded no result.

 

@amitchandak @Sahir_Maharaj 

My ScreenMy Screen

1 REPLY 1
Sahir_Maharaj
Super User
Super User

Hello @FarsH,

 

To generate the desired ranking, you can modify your approach and use the SWITCH function instead of IF statements to handle multiple conditions.

 

Could you please try this:

 

TopT =
VAR SelectedProduct = SELECTEDVALUE('Values'[Product SlicerP Order])
VAR SelectedMetric = SELECTEDVALUE('Values'[Metrics Value])
RETURN
SWITCH(
    SelectedMetric,
    "Net Sales", RANKX(FILTER(ALLSELECTED('Mediterranean Cameras Company'[Country], 'Mediterranean Cameras Company'[BuyerType], 'Mediterranean Cameras Company'[Month], 'Mediterranean Cameras Company'[Day]), 'Mediterranean Cameras Company'[Product] = SelectedProduct), [Net Sales],,DESC) <= 1,
    "Net Profit", RANKX(FILTER(ALLSELECTED('Mediterranean Cameras Company'[Country], 'Mediterranean Cameras Company'[BuyerType], 'Mediterranean Cameras Company'[Month], 'Mediterranean Cameras Company'[Day]), 'Mediterranean Cameras Company'[Product] = SelectedProduct), [Net Profit],,DESC) <= 1,
    "Net Profit Margin", RANKX(FILTER(ALLSELECTED('Mediterranean Cameras Company'[Country], 'Mediterranean Cameras Company'[BuyerType], 'Mediterranean Cameras Company'[Month], 'Mediterranean Cameras Company'[Day]), 'Mediterranean Cameras Company'[Product] = SelectedProduct), [Net Profit Margin],,DESC) <= 1,
    "Total Unit Sold", RANKX(FILTER(ALLSELECTED('Mediterranean Cameras Company'[Country], 'Mediterranean Cameras Company'[BuyerType], 'Mediterranean Cameras Company'[Month], 'Mediterranean Cameras Company'[Day]), 'Mediterranean Cameras Company'[Product] = SelectedProduct), [Total Unit Sold],,DESC) <= 1,
    BLANK()
)

 

The SWITCH function checks the selected metric value and uses the appropriate RANKX function to generate the ranking of top/bottom values based on the selected product.

 

The RANKX function filters the table based on the selected product and then calculates the ranking of the values based on the selected metric.

 

Let me know if you might require further assistance.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.