简体   繁体   中英

Count results across multiple conditions in Excel

I have the following table in which I want to compare scores across simulations for multiple players. How can I get the number of times that Phil Mickelson has a lower R1Score than Justin Rose?

在此处输入图像描述

This needs to be done in a formula of sorts, not using any PivotTables. I would need to compare the R1Score for Phil and Justin for SimNum 1, 2, 3, etc. to see how many times he beats Justin. Any help would be greatly appreciated!

If you have Office 365 you could use:

=SUM(IFERROR(--(FILTER(C2:C21,A2:A21="Phil Mickelson")>FILTER(C2:C21,A2:A21="Justin Rose")),0))

This is provided that the SimNum are in ascending order always.

If they're not in order but all values from 1 to x are present without any gaps, you could use the following:

=LET(value1,"Phil Mickelson",
     value2,"Justin Rose",
     data,A2:C21,
          sorted,SORTBY(data,INDEX(data,,2)),
     a,INDEX(sorted,,1),
     c,INDEX(sorted,,3),
       filter1,FILTER(c,a=value1),
       filter2,FILTER(c,a=value2),
SUM(IFERROR(--(filter1>filter2),0)))

If your version of Excel has dynamic arrays this is easy to solve.

Start with this formula:

=COUNTIFS($C$12:$C$21,">"&C2)

If we drag that down column D we get these numbers: 9, 8, 9, 6, 4, 4, 9, 0, 8, 2 ie Simulation 1 is better than 9 simulations of Justin Rose, simulation 2 is better than 8, simulation 10 is better than 2 etc.

With Dynamic Arrays, instead of just supplying the cell containing Phil's first simulation, we can now provide his entire simulation range as well. This will give us a dynamic array, containing the same numbers as our original COUNTIF formula. Take note that the range is surrounded by a blue border.

在此处输入图像描述

Now we just need to add all of these numbers together to show how many total simulations are better:

=SUM(COUNTIFS($C$12:$C$21,">"&C2:C11))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM