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?
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

etaf

Well-known Member
Joined
Oct 24, 2012
Messages
4,406
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
4,406
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
4,406
Office Version
  1. 365
Platform
  1. MacOS
you are welcome
 

Watch MrExcel Video

Forum statistics

Threads
1,122,719
Messages
5,597,736
Members
414,170
Latest member
Mdm

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