cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ManuApo
Helper I
Helper I

Struggling closing/writing IF statement :(

Hello community,

I am struggling closing an IF statement, it's almost done but there is something else I need to do. 

Basically when the if statement is calculated, I just want to in casa the result is -1, to give me a 0, else give me the result of the IF statement. 

I tried to do a nested IF statement:    IF( IF ( ...normal statement) = -1, 0 )  but it's not working. Doesn't give me back the results of the inside IF statement when it's not -1. 

 

Any thoughts??? 

I have attached a screenshot of the IF statement and the result. 

 

Thank you so much,
Manu

 

Capture.PNG

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @ManuApo 

Calculate the value first then check if it equals -1 and return the appropriate value

Use this code - note that I haven't typed out the entire CALCULATE. Please supply code as text raher than an image so it doesn't have to be retyped.

 

First answer by UW Timeline = 

VAR Res = CALCULATE( SUM('Calendar'[Workday]), .......

RETURN 

IF (Res = -1, 0, Res)

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @ManuApo 

Calculate the value first then check if it equals -1 and return the appropriate value

Use this code - note that I haven't typed out the entire CALCULATE. Please supply code as text raher than an image so it doesn't have to be retyped.

 

First answer by UW Timeline = 

VAR Res = CALCULATE( SUM('Calendar'[Workday]), .......

RETURN 

IF (Res = -1, 0, Res)

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Thank you so much @PhilipTreacy !! 

I dont know how I couldn't think about that one! 

Thanks again 🙂
Manu.

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors