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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I am trying to use the RANKX function to show my top 300 items by sales value. I also need to show this broken out by store and product division.
The catch is, I need it to adjust it's ranking so each store location has a top 300 items by sales value, but the product division does not change the rankings. So each Location would have 300 top selling skus, that I could see the number of by Division, but that division doesn't affect the rankings
My rankx formula is:
Top 300 SkusB = rankx(allselected('2016844 Ontario Ltd$Replen_ Item Quantity'[Item No_]),calculate(sum('2016844 Ontario Ltd$Value Entry$VSIFT$4'[Sales Amount (Actual)])))
Is there a way to have the division code excluded from the rankings when I put it in the ideal layout as shown below?
Top 300 for 1 location with division - want the total skus to be 300
top 300 all locations - this is correct
top 300 skus one location
Ideal Table Layout
@sarafenwick Any dummy data and desired results shared is appreciated.
See below for sample data. The desired result would rank as follows below... it would rank each location separately but not each division. So ideally I could show the out of stocks by location for the top 300 grossing skus, but be able to show which divisions those skus come from without showing the top 300 grossing skus by location by division.
Item No_ | Total Sales Value | Not in Stock | Total Skus | Location Code | Item Division Code |
100012 | 2530.97 | 1 | 1 | S14-MAIN | GR |
100013 | 5130.66 | 1 | S03-MAIN | GR | |
100013 | 5130.66 | 1 | S04-MAIN | GR | |
100013 | 5130.66 | 1 | S05-MAIN | GR | |
100013 | 5130.66 | 1 | S06-MAIN | GR | |
100013 | 5130.66 | 1 | S07-MAIN | GR | |
100013 | 5130.66 | 1 | S08-MAIN | GR | |
100013 | 5130.66 | 1 | S09-MAIN | GR | |
100013 | 5130.66 | 1 | S10-MAIN | GR | |
100013 | 5130.66 | 1 | S11-MAIN | GR | |
100013 | 5130.66 | 1 | S12-MAIN | GR | |
100013 | 5130.66 | 1 | S13-MAIN | GR | |
100014 | 5433.83 | 1 | DC-MAIN | GR | |
100014 | 5433.83 | 1 | S02-MAIN | GR | |
100014 | 5433.83 | 1 | S03-MAIN | GR | |
100014 | 5433.83 | 1 | S04-MAIN | GR | |
100014 | 5433.83 | 1 | S05-MAIN | GR | |
100014 | 5433.83 | 1 | S06-MAIN | GR | |
100014 | 5433.83 | 1 | S07-MAIN | GR | |
100014 | 5433.83 | 1 | S08-MAIN | GR | |
100014 | 5433.83 | 1 | S09-MAIN | GR | |
100014 | 5433.83 | 1 | S10-MAIN | GR | |
100014 | 5433.83 | 1 | S11-MAIN | GR | |
100014 | 5433.83 | 1 | S12-MAIN | GR | |
100014 | 5433.83 | 1 | S13-MAIN | GR | |
100033 | 15487.29 | 1 | 1 | S14-MAIN | DG |
100033 | 15487.29 | 1 | DC-MAIN | DG | |
100051 | 22407.19 | 1 | 1 | S13-MAIN | DG |
100051 | 22407.19 | 1 | S02-MAIN | DG | |
100051 | 22407.19 | 1 | S03-MAIN | DG | |
100051 | 22407.19 | 1 | S04-MAIN | DG | |
100051 | 22407.19 | 1 | S05-MAIN | DG | |
100051 | 22407.19 | 1 | S06-MAIN | DG | |
100051 | 22407.19 | 1 | S07-MAIN | DG | |
100051 | 22407.19 | 1 | S08-MAIN | DG | |
100051 | 22407.19 | 1 | S09-MAIN | DG | |
100051 | 22407.19 | 1 | S10-MAIN | DG | |
100051 | 22407.19 | 1 | S11-MAIN | DG | |
100051 | 22407.19 | 1 | S12-MAIN | DG |
Desired Result Ranking:
Item No_ | Total Sales Value | Not in Stock | Total Skus | Location Code | Item Division Code | Desired Rank Outcome |
100033 | 15487.29 | 1 | DC-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | DC-MAIN | GR | 2 | |
100051 | 22407.19 | 1 | S02-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S02-MAIN | GR | 2 | |
100051 | 22407.19 | 1 | S03-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S03-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S03-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S04-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S04-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S04-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S05-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S05-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S05-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S06-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S06-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S06-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S07-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S07-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S07-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S08-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S08-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S08-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S09-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S09-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S09-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S10-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S10-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S10-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S11-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S11-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S11-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | S12-MAIN | DG | 1 | |
100014 | 5433.83 | 1 | S12-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S12-MAIN | GR | 3 | |
100051 | 22407.19 | 1 | 1 | S13-MAIN | DG | 1 |
100014 | 5433.83 | 1 | S13-MAIN | GR | 2 | |
100013 | 5130.66 | 1 | S13-MAIN | GR | 3 | |
100033 | 15487.29 | 1 | 1 | S14-MAIN | DG | 1 |
100012 | 2530.97 | 1 | 1 | S14-MAIN | GR | 2 |
Try with this:
Ranking = CALCULATE(RANKX(ALLSELECTED(Table1[Item No_]);CALCULATE(SUM(Table1[Total Sales Value])));ALLEXCEPT(Table1;Table1[Item No_];Table1[Location Code]))
This is very close. I can now get it in a table like below and it does rank properly... the issue is when i try to summarize the data by division and location in a matrix.
I want to filter the rank to top 300. Which is fine for the table, but in the matrix it is showing all values and not taking the 300 filter into account. Any thoughts? As you can see in the table the total skus are 300 which is right, the matrix has 6768 but should total to only 300.
Table of Top 300
Matrix of Top 300
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.