Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Sharing a sample project to explain the problem
I have a matrix where I need to rank States by a metric called MSRP Delta (The difference between SALES and MSRP) in descending order. The rankings (among other measures brought back) are broken down by the column "DEALSIZE" so there'll be measure summaries for each and a final Row Total at the end.
The measure is calculated as:
MSRP Delta = SUM(sales_data_sample[SALES]) - sum(sales_data_sample[MSRP])
I'm using a Top N Parameter table with GENERATESERIES and have placed this value into a slicer. When the user selects the 'N' value in a slicer, a measure only return rankings of MSRP Delta by State that are less than or equal to the value N. This can be seen in this main function:
Rank States Sales-Delta Top N =
Var _topN = SELECTEDVALUE('Top N Parameter'[Value])
RETURN SWITCH(TRUE(), RANKX(ALLSELECTED(sales_data_sample[STATE]),CALCULATE([MSRP Delta]),,DESC,Dense) <= _topN,RANKX(ALLSELECTED(sales_data_sample[STATE]),CALCULATE([MSRP Delta]),,DESC,Dense),BLANK())
Finally, to only return matrix values that meet this criteria, I have the visual filter "Filter out blank values" set so any non-ranked STATES are removed.
Initially, it appears that the calculation returns roughly what i want in a matrix overall before applying the visual filter; for example when I set 'N=7' and have a slicer on the 'Status' column active. The column break downs are producing false ties and skipped ranks but the overall score appears correct.
However, when I apply the visual filter to remove blanks I get the following table. With Top N = 7, it's now missing the 7th place value and again producing incorrect duplicate rankings for the column breakdowns.
I need to fix the filter context of this calculation to avoid these silly results being returned and to bring back the correct amount of unique rows for any Top N selected. So if I keep N=7 and my slicers selected, it should return the top 7 based on overall row total only, remove false ties, avoid rank skips and ignore rows such as BC which are non-ranked overall.So a table output of that description should look like (ignoring other measures to be brought back):
Medium | Small | Overall | |
DEALSIZE | Ranks States Sales-Delta | Ranks States Sales-Delta | Ranks States Sales-Delta |
CT | 6 | 7 | |
PA | 5 | 6 | 6 |
Victoria | 7 | 4 | 5 |
NSW | 4 | 5 | 4 |
NY | 3 | 3 | 3 |
MA | 2 | 2 | 2 |
CA | 1 | 1 | 1 |
Total | 1 | 1 | 1 |
I just can't wrap my head around where I'm going wrong in the filter context - it's probably something really easy but I've spent forever tweaking and the result largely comes up the same. Can someone please help me understand where I'm going wrong with this?
Here's a sample PBIX that covers the above scenario and provides all relevant visuals, measures and associated fields: https://drive.google.com/file/d/1mOPZ1a5Bi_KY5L88K0drYFrmMPoUs0E_/view?usp=drive_link
Regards,
Solved! Go to Solution.
Hi,
PBI file attached.
Thank you Ashish, this appears to be what I needed and I appreciate it immensely.
You are welcome.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
87 | |
81 | |
53 | |
37 | |
35 |