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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
KCinMelbourne
Resolver I
Resolver I

How to End a Query if Condition is Met (Query Editor / M)

Hi all,

 

I am looking for a solution that says:

if <condition> then <perform action> else <end query> 

Is this possible in M?

 

Also there are a number of queries where if a condition is met, I effectively don't want the query to execute at all. Is that possible?  For example:

 

if <Parameter A = "Disable"> then  <end query without any content> else <query actions>

Cheers

Kirsty 

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @KCinMelbourne,

 

Please check if below blog helpful to your scenario:

Conditional Code Branching in Power BI Query: if...then...else => then...else...if

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @KCinMelbourne,

 

Please check if below blog helpful to your scenario:

Conditional Code Branching in Power BI Query: if...then...else => then...else...if

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Perfect, thank you!

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.