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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Predominant Value From Sum of Column

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.

 

YearNameItemSalesPredominant Item Sold
2017JohnCar10Motorcycle
2017JohnTruck15Motorcycle
2017JohnMotorcycle25Motorcycle
2017MikeCar50Car
2017MikeTruck10Car
2017MikeMotorcycle10Car
2018JohnCar40Car
2018JohnTruck15Car
2018JohnMotorcycle15Car
2018MikeCar10Truck
2018MikeTruck30Truck
2018MikeMotorcycle5Truck

 

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:

 

https://community.powerbi.com/t5/Desktop/How-to-obtain-the-most-common-value-from-a-column-and-displ...

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

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.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.