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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
dehmos27
Frequent Visitor

How can I stop a query from proceeding to the next steps if the table is blank?

I have a scenario where I want to prevent a query from erroring out if a table is blank by stopping it from evaluation additional steps. Is there a way to do this?

 

Here's the background: a dataset is extracted from a system as one file type, but the query only works with files of a specific type, so I want to stop the query from running if the referenced file is NOT of the correct file type but leave the report blank instead of erroring out.

2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

Multiple ways you can do this.  If the file is one of many, but has an error, you can add a step to remove errors (right click on that column to see that option) before proceeding.  If it is the only file, you can build a "try ... otherwise" in your query somewhere at the step level 

 

step= try prevstep otherwise null (or some acceptable output)

 

Not sure what you'll need to do with your otherwise w/o seeing the rest of your query, but you can use it to substitute in dummy data that works, null, etc. 

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

edhans
Super User
Super User

Try this. 
 
Do the query as normal. Then for the last step add something like this. Add a new step to your query by right-clicking on the last step and adding another step. type this in the formula bar:
 
= if Table.IsEmpty(#”Step Where it could be empty”) then null else #”Previous Step”
 
(My iPhone is putting weird quotes here so fix those if you copy paste)
 
You may need to replace null with something else if null will cause problems later on or have other error handling in subsequent queries to handle the null. 
 
I’d really have to see what the query is doing and how it is being relied upon later to be more specific. 


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

Try this. 
 
Do the query as normal. Then for the last step add something like this. Add a new step to your query by right-clicking on the last step and adding another step. type this in the formula bar:
 
= if Table.IsEmpty(#”Step Where it could be empty”) then null else #”Previous Step”
 
(My iPhone is putting weird quotes here so fix those if you copy paste)
 
You may need to replace null with something else if null will cause problems later on or have other error handling in subsequent queries to handle the null. 
 
I’d really have to see what the query is doing and how it is being relied upon later to be more specific. 


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
mahoneypat
Microsoft Employee
Microsoft Employee

Multiple ways you can do this.  If the file is one of many, but has an error, you can add a step to remove errors (right click on that column to see that option) before proceeding.  If it is the only file, you can build a "try ... otherwise" in your query somewhere at the step level 

 

step= try prevstep otherwise null (or some acceptable output)

 

Not sure what you'll need to do with your otherwise w/o seeing the rest of your query, but you can use it to substitute in dummy data that works, null, etc. 

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors