COUNTIF or SUMPRODUCT?

potter007

New Member
Joined
Aug 15, 2006
Messages
31
Hello all

I have table of data and i'm after details from one column to give me a total count. The data in column from row 9 to 125 is a mixture of percentages. What I'm trying to get is a count of the range that is <10%, 10.01%-25%, 25%-50%, 50%-75% & 75%-100% so that i can display this in a new worksheet to give a pie chart of the data.

So far I have been able to do the <10% results using COUNTIF but when I apply it to the others I'm getting percentage results rather than counts.

Here is an example of the formula I used:

=COUNTIF(D9:D125,">10.01%)-COUNTIF(D9:D125,"<25%")

Can anyone guide me as to where I'm going wrong?

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Your original approach is OK, but you need to reverse < in the second COUNTIF, try this to count any percentage >=10% but < 25%

=COUNTIF(D9:D125,">=10%")-COUNTIF(D9:D125,">=25%")

You are counting all the %s above 10% and then subtarcting the number above 25% thereby getting a count of all those between
 
Upvote 0
But if he doesn't want .1 included and does want .25 included... ">" & .1 and ">" & .25

What surprised me was that this actually returned #VALUE errors:
{=COUNTIF(IF((range>.1)*(range<=.25),range,FALSE),TRUE)}
{=COUNTIF(IF((range>.1)*(range<=.25),range,0),1)}
 
Upvote 0
Well maybe, Asator....here's what potter007 says

.....get is a count of the range that is <10%, 10.01%-25%, 25%-50%, 50%-75% & 75%-100%....

If you take that literally then 10% exactly doesn't get counted in any range, and 25%, 50% and 75% exactly will all be counted twice. I took a chance and assumed that wasn't the requirement.

If you understand the principle then the specifics can be adjusted as required.

Another way that might be more transparent

would be to use SUMPRODUCT, i.e.

=SUMPRODUCT((D9:D125>=10%)*(D9:D125<25%))

That should give exactly the same result as the previous formula I suggested
 
Upvote 0
Your original approach is OK, but you need to reverse < in the second COUNTIF, try this to count any percentage >=10% but < 25%

=COUNTIF(D9:D125,">=10%")-COUNTIF(D9:D125,">=25%")

You are counting all the %s above 10% and then subtarcting the number above 25% thereby getting a count of all those between

Many Thanks, I thought I was on the right tracks but just couldn't work out where I was going wrong.
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top