Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
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.
My Screen
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.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 76 | |
| 38 | |
| 31 | |
| 27 | |
| 26 |