Adjust dividing formula when a value is zero

vladimiratanasiu

Active Member
Joined
Dec 17, 2010
Messages
347
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello!

I have a table, presenting electricity consumption of a client and its variation (+/-) from one month vs. the same one of the previous year. Sometimes, there are months with no consumption (see B21, B22, B26). My formula works fine when two similar months with non-zero values are compared. However, when the first one is zero (e.g. B21, B22, B26) and the next is non-zero (e.g. B34, B35, B39), I need the proper result should be a negative / positive number (E34, E35, E39), but my formula generates 0. How could adjust / change it, in order to get the necessary value?
Thank you!
Book2.xlsx
ABCDE
1Electrictricity consumption Annual differences (%)
2PeriodKwhValue (RON, including VAT)Consumption (Kwh)
3
4Jan-2254.0036.57
5Feb-2266.0044.70
6Mar-2278.0053.04
7Apr-2268.0046.25
8May-22-10.00-7.12
9Jun-220.000.00
10Jul-220.000.00
11Aug-2249.0033.32
12Sep-2227.0018.13
13Oct-2251.0034.62
14Nov-220.000.00
15Dec-220.000.00
16
17Jan-2349.9744.70-7.46%
18Feb-2316.1253.04-75.58%
19Mar-23106.0064.9835.90%
20Apr-2396.0064.6741.18%
21May-2346.0031.72-560.00%
22Jun-23188.000.00%18800%
23Jul-23144.000.00%14400%
24Aug-23-100.00%
25Sep-23-100.00%
26Oct-23-100.00%
27Nov-23-4.000.00%-400%
28Dec-230.00%
Sheet1
Cell Formulas
RangeFormula
D17:D28D17=IFERROR(-(1-B17/B4),0)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I attach a new table, including the updated data according with the cell references from my previous message. Thank you.
Book2.xlsx
ABCDE
1Electrictricity consumption Annual differences
2PeriodKwhValue (RON, including VAT)Consumption (Kwh)
3Jan-2167.820.00
4Feb-2161.25104.51
5Mar-2159.190.00
6Apr-2148.36100.60
7May-2149.970.00
8Jun-2148.3679.73
9Jul-2149.970.00
10Aug-2116.1280.09
11Sep-2167.000.00
12Oct-2111.0063.77
13Nov-2144.0035.97
14Dec-210.000.00
15
16Jan-2254.0036.57-20.38%
17Feb-2266.0044.707.76%
18Mar-2278.0053.0431.78%
19Apr-2268.0046.2540.61%
20May-22-10.00-7.12-120.01%
21Jun-220.000.00-100.00%
22Jul-220.000.00-100.00%
23Aug-2249.0033.32203.97%
24Sep-2227.0018.13-59.70%
25Oct-2251.0034.62363.64%
26Nov-220.000.00-100.00%
27Dec-220.000.000.00%
28
29Jan-2349.9744.70-7.46%
30Feb-2316.1253.04-75.58%
31Mar-23106.0064.9835.90%
32Apr-2396.0064.6741.18%
33May-2346.0031.72-560.00%
34Jun-23188.000.00%18800%
35Jul-23144.000.00%14400%
36Aug-23-100.00%
37Sep-23-100.00%
38Oct-23-100.00%
39Nov-23-4.000.00%-400%
40Dec-230.00%
Sheet1
Cell Formulas
RangeFormula
D16:D27,D29:D40D16=IFERROR(-(1-B16/B3),0)
 
Upvote 0
I attach a new table, including the updated data according with the cell references from my previous message. Thank you.
Book2.xlsx
ABCDE
1Electrictricity consumption Annual differences
2PeriodKwhValue (RON, including VAT)Consumption (Kwh)
3Jan-2167.820.00
4Feb-2161.25104.51
5Mar-2159.190.00
6Apr-2148.36100.60
7May-2149.970.00
8Jun-2148.3679.73
9Jul-2149.970.00
10Aug-2116.1280.09
11Sep-2167.000.00
12Oct-2111.0063.77
13Nov-2144.0035.97
14Dec-210.000.00
15
16Jan-2254.0036.57-20.38%
17Feb-2266.0044.707.76%
18Mar-2278.0053.0431.78%
19Apr-2268.0046.2540.61%
20May-22-10.00-7.12-120.01%
21Jun-220.000.00-100.00%
22Jul-220.000.00-100.00%
23Aug-2249.0033.32203.97%
24Sep-2227.0018.13-59.70%
25Oct-2251.0034.62363.64%
26Nov-220.000.00-100.00%
27Dec-220.000.000.00%
28
29Jan-2349.9744.70-7.46%
30Feb-2316.1253.04-75.58%
31Mar-23106.0064.9835.90%
32Apr-2396.0064.6741.18%
33May-2346.0031.72-560.00%
34Jun-23188.000.00%18800%
35Jul-23144.000.00%14400%
36Aug-23-100.00%
37Sep-23-100.00%
38Oct-23-100.00%
39Nov-23-4.000.00%-400%
40Dec-230.00%
Sheet1
Cell Formulas
RangeFormula
D16:D27,D29:D40D16=IFERROR(-(1-B16/B3),0)
Try this...

In your IFERROR formula, replace the zero with a "1*cell in B column".

For example, the formula in D34 would be:

=IFERROR(-(1-B34/B21),1*B34)

Have a question though. Shouldn't these scenarios show 100% instead? After all, when there's electricity consumption in the prior year but not the current year, you show -100% like in cells D36 through D38. Shouldn't the opposite scenario show a positive 100%? If you prefer this instead, replace the 0 with a 1 in your IFERROR formula.
 
Upvote 0
Solution
Try this...

In your IFERROR formula, replace the zero with a "1*cell in B column".

For example, the formula in D34 would be:

=IFERROR(-(1-B34/B21),1*B34)

Have a question though. Shouldn't these scenarios show 100% instead? After all, when there's electricity consumption in the prior year but not the current year, you show -100% like in cells D36 through D38. Shouldn't the opposite scenario show a positive 100%? If you prefer this instead, replace the 0 with a 1 in your IFERROR formula.
Thank you for the answer and solution to my problem. Regarding your question, the value 100% will indicate a positive consumption. It means that the client used twice as much energy, comparing with the same month from the previous year. But the real consumption is zero, so the difference will be negative(-100%). The same scenario is available conversely too, when the present value is positive and the last one negative.
 
Upvote 0
Try this...

In your IFERROR formula, replace the zero with a "1*cell in B column".

For example, the formula in D34 would be:

=IFERROR(-(1-B34/B21),1*B34)

Have a question though. Shouldn't these scenarios show 100% instead? After all, when there's electricity consumption in the prior year but not the current year, you show -100% like in cells D36 through D38. Shouldn't the opposite scenario show a positive 100%? If you prefer this instead, replace the 0 with a 1 in your IFERROR formula.
I have one more question: in cell D3, the result is mathematically correct (-560%). Anyway, in normal terms the real consumption is positive (+560%), comparing the two months. How could I express this special situation in the present formula / a distinct one, so as the final result to be +560% ? Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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