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

How Do I Write This IF Error Statement in Power Query & Power BI Desktop

I have the following formula in an excel sheet =IFERROR(IF(V2="",0,IF(W2<>"",W2-T2,Lookups!$L$1-T2)),0) and it does a vlookup to another tab with the prior date. In Power Query I now have a column that shows the Prior Date which is yesterday's date. Now I am needing to understand how I can write this IF Error statement in Power Query. I tried writing it just like I did in the normal excel sheet, but the "", is not recognized in Power Query and I get an error message for Incorrect Syntax. The breakdown is below:

 

=IFERROR(IF(V2="",0,IF(W2<>"",W2-T2,Lookups!$L$1-T2)),0)
V2 = confirmed start date
W2 = confirmed drop date
T2 = requested start date
L$1$ = Prior Date 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How Do I Write This IF Error Statement in Power Query & Power BI Desktop

HI @lbrown,

 

You can take a look at below links about error handling in dax and m query:

Error-handling in Power Query

IFERROR Function (DAX)

 

For your measure, it can be transform as below measure:

Result =
VAR prior = xxxx
VAR V2 = xxx
VAR W2 = xxx
VAR T2 = xxx
RETURN
    IFERROR ( IF ( V2 = "", 0, IF ( W2 <> "", W2 - T2, prior - T2 ) ), 0 )

I'm not clear how you get these variables, so I use var function to define them as variables .

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: How Do I Write This IF Error Statement in Power Query & Power BI Desktop

HI @lbrown,

 

You can take a look at below links about error handling in dax and m query:

Error-handling in Power Query

IFERROR Function (DAX)

 

For your measure, it can be transform as below measure:

Result =
VAR prior = xxxx
VAR V2 = xxx
VAR W2 = xxx
VAR T2 = xxx
RETURN
    IFERROR ( IF ( V2 = "", 0, IF ( W2 <> "", W2 - T2, prior - T2 ) ), 0 )

I'm not clear how you get these variables, so I use var function to define them as variables .

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

Highlighted
Helper I
Helper I

Re: How Do I Write This IF Error Statement in Power Query & Power BI Desktop

Hi @v-shex-msft

 

I checked out the links. I'm not quite sure what you mean by the variables andthe var function to define the variables. I entered the formula below into Power Query Editor and received error message:

 

Expression.Error: The name 'iferror' wasn't recognized.  Make sure it's spelled correctly.

 

Formula I entered in Power Query Editor: 

=iferror( IF ( [CONFIRMED_START_DATE] = "", 0, IF ( [CONFIRMED_DROP_DATE] <> "", [CONFIRMED_DROP_DATE] - [REQUESTED_START_DATE], [Prior Date] - [REQUESTED_START_DATE]) ), 0 )

 

 

Highlighted
Community Support
Community Support

Re: How Do I Write This IF Error Statement in Power Query & Power BI Desktop

Hi @lbrown,

 

My formula is dax version, it not works for power query. You also need to input variable before use it..


Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Highlighted
Helper I
Helper I

Re: How Do I Write This IF Error Statement in Power Query & Power BI Desktop

Hi Xiaoxin,

 

I didn't realize your formula was the Dax version, but I used this formula and included the correct column names for the variables and this worked. Thanks for your help.

 

Best,

Lauren

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors