# If(count()) question

#### rockhopper

##### New Member
I'm trying to add the top seven values from 20 columns of numbers (represented by "Races", but all columns may not have values in them. When <7 columns have numbers, sum just all of them. The function I've written is below, but is now working:

=IF(COUNT(Races >6), SUM(LARGE(Races, 1), LARGE(Races, 2), LARGE(Races, 3), LARGE(Races, 4), LARGE(Races, 5), LARGE(Races, 6), LARGE(Races, 7) ), SUM(Races))

### Excel Facts

Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

##### Well-known Member
Is Races multiple rows? Or is it just 1 row? And if it's multiple rows, you want the 7 largest column sums, correct?

##### Well-known Member
Is there some reason this won't work instead?

Excel Workbook
ABCDEFGHIJKLMNOPQRST
1Data 1Data 2Data 3Data 4Data 5Data 6Data 7Data 8Data 9Data 10Data 11Data 12Data 13Data 14Data 15Data 16Data 17Data 18Data 19Data 20
247122019528837186848735395547618124883
31758883008201315691098688733983855758
44988572831237980579953564660763551515
5789995152218483176574729195177889234
624951595352482773215688204368559497705
79285687299048764656473149730239617965
83951621611847755877274175381162123869
958394620665726957958612026051647387259
10786402170550968353885976905108855212910
11
12
13Sum:6846
141988
152986
163983
174980
185976
196968
207965
Sheet1

#### rockhopper

##### New Member
After fighting this for a couple hours, I fought it some more. I swear my logic was correct, but it wasn't working. Anyways, thanks. Here's what ended up working for me, my >6 was placed count(races >6):

=IF(COUNT(Races) >6, SUM(LARGE(Races, {1,2,3,4,5,6,7}) ), SUM(Races))

##### Well-known Member
What I don't get is why you even use the IF. You want the 7 biggest values. Empty cells will be zeroes. Why not just make the formula:
=SUM(LARGE(Races, {1,2,3,4,5,6,7}))

#### rockhopper

##### New Member
When I tried to sum the 7 largest values when there was less the 7, I was getting an error, so I had to create case for a racer who had less then 7 races.

#### shemayisroel

##### Well-known Member
Ok so has the problem been resolved?

Replies
4
Views
160
Replies
0
Views
149
Replies
0
Views
374
Replies
1
Views
649
Replies
1
Views
247

1,195,856
Messages
6,011,976
Members
441,661
Latest member
Pammie007

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back