Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

IF AND STATEMENT Measure Power Query

I have two columns: 1. predicted precipitation (Table1[Prediction]) and 2. actual precipitation (Table2[Real]) and I want to test 4 conditions:
a. predicted precipitation/observed precipitation
b. precipitation predicted/precipitation not observed
c. precipitation not forecasted/precipitation observed
d. unpredicted precipitation/unobserved precipitation

I tested this measure for option a:
IF(ISBLANK(Table1[Prediction]);BLANK();IF(AND(Table2[Actual] > 0;Table1[Prediction] > 0);0;1))

However, in cases where prediction is 0 and reality is 0.2, the result of the measure is 0, when it should be 1, because only one of the conditions is true.

I can't get over this obstacle.

I thank you in advance for your help.

 

1 ACCEPTED SOLUTION

Hi,

i hope this time it's good (i printed your solution to verify)

P = IF('Table'[Column1]=0,1,If(and('Table'[Column1]>=0,'Table'[Column2]>0),0,1))

serpiva64_0-1668166691092.png

 

View solution in original post

10 REPLIES 10
serpiva64
Solution Sage
Solution Sage

Please,

can you post an exemple of your tables and of expeted results?

Anonymous
Not applicable

Captura de ecrã 2022-11-11 104304.png

Thank you in advance for your interest in helping me. This is an example of my values, the result I expect to get and what, with the formula I posted initially, I am getting.

Hi,

try this 

P = IF(and('Table'[Column1]>=0,'Table'[Column2]>0),0,1)
(adapt , and columns name to your case)

 

serpiva64_0-1668164741115.png

If this post is useful to help you to solve your issue consider giving the post a thumbs up 

 and accepting it as a solution !

 

Anonymous
Not applicable

Thanks for the suggestion, but unfortunately it doesn't solve the issue I raised.
If you notice, in the case where the prediction is 0 and the reality is 0.2, the result should be "1" and not "0".

Sorry, 

to many 1 and 0!

try this

P = IF(and('Table'[Column1]=0,'Table'[Column2]=0),1,If(and('Table'[Column1]>=0,'Table'[Column2]>0),0,1))

serpiva64_0-1668165587368.png

 

Anonymous
Not applicable

Thank you for another suggestion. However, the result is the same. If you notice in the table you shared with me, the result is still "0" instead of "1".serpiva64_0-1668165587368.png

Hi,

i hope this time it's good (i printed your solution to verify)

P = IF('Table'[Column1]=0,1,If(and('Table'[Column1]>=0,'Table'[Column2]>0),0,1))

serpiva64_0-1668166691092.png

 

Anonymous
Not applicable

Thank you once again. I see that in your table, the formula works, but in mine, unfortunately not. I still get 0. I don't understand why.

Please post the new formula you are using

Anonymous
Not applicable

I already know why it didn't work and it's embarrassing. It wasn't a 0, but a 0.3 the prediction. I apologize for wasting your time. Thank you very much for your help.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.