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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

How to create if then statement in Power Query based on Error in value across three columns?

I have three columns all with dates in the them, but some of the dates of 'Error'. I want to create a new column that takes the first value that doesn't have an 'Error'.

I can get this to work in excel with this formula: =IFERROR(A1,IFERROR(B1,C1)) what is the equivalent formula for Power Query?

See screen shot for example. The green check marks are the values I'm trying to get into one column

error4.png

1 ACCEPTED SOLUTION
Tad17
Solution Sage
Solution Sage

Hey @Anonymous 

 

You can use try/otherwise as shown in this thread: https://community.powerbi.com/t5/Desktop/Power-Query-M-code-equivalent-to-quot-iferror-quot-function/td-p/281479

 

You can follow the guidelines in this article: https://www.poweredsolutions.co/2019/06/18/error-handling-iferror-in-power-bi-power-query/

 

You can use the Find & replace in the Query Editer in Power BI which will add a step to the query to replace errors with a string of your choosing.

 

Or you can use a calculated column with the IFERROR function: https://docs.microsoft.com/en-us/dax/iferror-function-dax

 

If this helps please kudo.

If this solves your problem please accept it as a solution.

View solution in original post

2 REPLIES 2
az38
Community Champion
Community Champion

 Hi @Anonymous 

use "Replace Error" option. rigth-click to data column and replace error values to "0"

then use statement like

= if [Clean Date 2] = 0 then [Clean Date 3] else if .. then ... else ...

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Tad17
Solution Sage
Solution Sage

Hey @Anonymous 

 

You can use try/otherwise as shown in this thread: https://community.powerbi.com/t5/Desktop/Power-Query-M-code-equivalent-to-quot-iferror-quot-function/td-p/281479

 

You can follow the guidelines in this article: https://www.poweredsolutions.co/2019/06/18/error-handling-iferror-in-power-bi-power-query/

 

You can use the Find & replace in the Query Editer in Power BI which will add a step to the query to replace errors with a string of your choosing.

 

Or you can use a calculated column with the IFERROR function: https://docs.microsoft.com/en-us/dax/iferror-function-dax

 

If this helps please kudo.

If this solves your problem please accept it as a solution.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.