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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello-
I want a caclulated column that displays the highest rank value based on sum of another column, for all rows where two columns match.
So, as a dummy example from the data below, I need to calculate the "Predominant Item Sold" column based on summing the "Sales" values for all rows matching both the "Year" and the "Name." The Car, Truck, or Motorcycle would show as predominant because it was the highest summed value for that Year/Name combination.
| Year | Name | Item | Sales | Predominant Item Sold |
| 2017 | John | Car | 10 | Motorcycle |
| 2017 | John | Truck | 15 | Motorcycle |
| 2017 | John | Motorcycle | 25 | Motorcycle |
| 2017 | Mike | Car | 50 | Car |
| 2017 | Mike | Truck | 10 | Car |
| 2017 | Mike | Motorcycle | 10 | Car |
| 2018 | John | Car | 40 | Car |
| 2018 | John | Truck | 15 | Car |
| 2018 | John | Motorcycle | 15 | Car |
| 2018 | Mike | Car | 10 | Truck |
| 2018 | Mike | Truck | 30 | Truck |
| 2018 | Mike | Motorcycle | 5 | Truck |
The answer in this post below comes close, which uses the TopN and the RANKX functions, but I don't think it takes into consideration summing a value based on more than one column:
Solved! Go to Solution.
I think I may have answered my own question. It should be something like this:
Predominant Item Sold = FIRSTNONBLANK(TOPN(1,VALUES('Table'[Item]),RANKX(ALL('Table'[Item]),CALCULATE(Sum('Table'[Sales]),ALLEXCEPT('Table','Table'[Name],'Table'[Year])),,ASC)),1)
The CALCULATE and the ALLEXCEPT are the part I couldn't think of earlier. Let me know if anyone else has an alternative solution.
I think I may have answered my own question. It should be something like this:
Predominant Item Sold = FIRSTNONBLANK(TOPN(1,VALUES('Table'[Item]),RANKX(ALL('Table'[Item]),CALCULATE(Sum('Table'[Sales]),ALLEXCEPT('Table','Table'[Name],'Table'[Year])),,ASC)),1)
The CALCULATE and the ALLEXCEPT are the part I couldn't think of earlier. Let me know if anyone else has an alternative solution.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 58 | |
| 45 | |
| 42 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 171 | |
| 110 | |
| 91 | |
| 55 | |
| 45 |