# If Formula

#### Hoopsah

##### Board Regular
Hi

Trying to write a formula that would calculate:

If D5 = 0 then 0 else B5-D5, If B5=0 then 0 else B5 - D5

if(D5=0,0,(B5-D5),if(B5=0,0,B5-D5))

Can't get it to work properly

Any help would be appreciated.

### Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

#### excelpunk

##### Board Regular
Try this
=if(or(D5=0,B5=0),0,(B5-D5))

#### Jugantarji

##### Board Regular
You could try

=IF(OR(B5=0,D5=0),0,(B5-D5))

#### Hoopsah

##### Board Regular
Thanks guys,

Works perfectly

Cheers

Hoopsah

Replies
4
Views
271
Replies
1
Views
251
Replies
2
Views
91
Replies
0
Views
233
Replies
2
Views
125

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.

1,163,561
Messages
5,832,507
Members
430,136
Latest member
Asir Jefferson

### 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