# best practice for multiple if conditions

#### dickson30

##### New Member
Hi hoping someone can help I've got multiple if statement which I would be fine writing in excel but struggling in powerquery (the below is not working expecting another then?!) would appreciate any help and what the best practice would be for the below and if anyone can make it work that would be great. Thank you.

then if[Pear]>0
then if[Banana]>0
then if [Apple]>0
then ([Banana]+[Pear]+[Apple])/3
else if [Apple Juice]<0
Then 0
else ([Pear]+[Banana])/2
else if [Apple]>0
then ([Pear]+[Apple])/2
else if [Banana Smoothie]>0
then [Pear]
else 0
else if [Banana]>0
Then if [Apple]>0
then if [pear juice]<0
then ([Banana]+[apple])/3
else [Banana]+[apple])/2
else if [pear juice]<0
then [Banana]/2
else [Banana]
else if [Apple]> 0
then if [Banana Smoothie]<0
then 0
else if [pear juice]<0
then [Apple]/2
else [Apple]
else 0
else 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.

#### VBA Geek

##### MrExcel MVP
you have some then with capital T

#### dickson30

##### New Member
Thank you I re went through the code there was also a couple of other minor mistakes but got it running, so now I just wonder is there a better way to write the query?

#### VBA Geek

##### MrExcel MVP
Thank you I re went through the code there was also a couple of other minor mistakes but got it running, so now I just wonder is there a better way to write the query?

It depends on your business logic, I have notices there are some ifs that can be grouped with 'and' conditions

Replies
1
Views
314
Replies
0
Views
138
Replies
1
Views
692
Replies
0
Views
390
Replies
0
Views
3K

1,186,165
Messages
5,956,332
Members
438,247
Latest member
UZev

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

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