ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Top 5 Sumif function? (https://www.excelbanter.com/excel-worksheet-functions/122898-top-5-sumif-function.html)

bestrugger

Top 5 Sumif function?
 
I'm looking to add only the top 5 in a list of n records. Is that possible?
Something to the extent of

=sumifTOP(range, criteria, addrange,top#)

Doable? or something similar


daddylonglegs

Top 5 Sumif function?
 
Here's an example

=SUM(LARGE(IF(A1:A10="x",B1:B10),{1,2,3,4,5}))

sums the top 5 values in B1:B10 where A1:A10 ="x"

Note this will only sum 5 values even if there are ties

If you may have less than 5 values where the criteria is met then to sum the
top 5 or all if there are less than 5 then you could try

=IF(COUNTIF(A1:A10,"x"),SUM(LARGE(IF(A1:A10="x",B1 :B10),ROW(INDIRECT("1:"&MIN(5,COUNTIF(A1:A10,"x")) )))),0)

confirmed with CTRL+SHIFT+ENTER



"bestrugger" wrote:

I'm looking to add only the top 5 in a list of n records. Is that possible?
Something to the extent of

=sumifTOP(range, criteria, addrange,top#)

Doable? or something similar



All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com