Calculate percentage, ignoring zeros

Gijs

New Member
Joined
May 29, 2012
Messages
30

m
n
13
90
14
91
15
92
16
92
17365
18
3337%
=m18/m13
19
0
20
0
21
0
2233
814%

<tbody>
</tbody>


  • n22 should be 37%
  • n22: 9% -- includes zeros, delivers a wrong percentage
    =m22/m17
  • n22: 814% -- Trying to avoid zeros, delivers a wrong percentage.
    =SUMPRODUCT(m18:m21,m13:m16)/SUMPRODUCT(--(m18:m21<>""),m13:m16)
Does anyone have an idea how so solve this?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
5,649
Office Version
  1. 365
Platform
  1. MacOS
can you use a sumif() / countif()
 

Gijs

New Member
Joined
May 29, 2012
Messages
30
Thanks etaf for your fast response on this sunny Sunday.
Regrettably your advice 'a sumif() / countif()' is too cryptic for me. I tried =SUMIF(M19:M22,">0")/COUNTIF(M14:M17,">0") which evidently doesn't work. Can you clarify the usage of 'sumif() / countif()'?
 

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
5,649
Office Version
  1. 365
Platform
  1. MacOS
try
=SUMIF(M19:M22,"<>"&0)/COUNTIF(M14:M17,"<>"&0)
 

Gijs

New Member
Joined
May 29, 2012
Messages
30
Thanks again etaf, especially your efforts to solve my question on a sunny Sunday.

Mulling over the challenge, I realized I wasn't clear in posting the question. What I needed is a weighted percentage, which I've meanwhile resolved with a somewhat convoluted formula:
=IF(N22>"",SUM(M19:M22)/SUM(M14:M17),
IF(N21>"",SUM(M19:M21)/SUM(M14:M16),
IF(N20>"",SUM(M19:M20)/SUM(M14:M15),N19)))

Thanks again for your fast response. Have a great week ahead.
 

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
5,649
Office Version
  1. 365
Platform
  1. MacOS
you are welcome
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,876
Messages
5,834,194
Members
430,263
Latest member
abz54

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
Top