Home > Software engineering >  Find Top 5 Values With the Highest Sums
Find Top 5 Values With the Highest Sums

Time:01-24

I have two columns. Column A has names and Column B has dollar amounts.

I am looking to find the combined sum of each value in Column A and display the top 5 results.

I have tried multiple query formulas to no avail. I have looked through Stack Overflow but have not found an example that matches my problem.

Screenshot example is included below.

[![Screenshot](https://i.stack.imgur.com/PLHX0.png)](https://i.stack.imgur.com/PLHX0.png)

CodePudding user response:

you can also try:

SORTN(BYROW(UNIQUE(A:A),LAMBDA(z,{z,SUMIF(A:A,z,B:B)})),5,,2,0)

CodePudding user response:

Try with this QUERY that sums B grouping by A, orders the sums in descendent order and limits to 5 results

=QUERY(A:B,"Select A,SUM(B) group by A order by SUM(B) desc limit 5",)
  • Related