Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
I'm running a query which returns a record with a number of fields. If the record contains the field 'CashField', the query continues as normal. However, if the field does NOT exist, is there a way to terminate the query cleanly and exit the function i.e. not subsequent steps from running?
let
Source = Excel.CurrentWorkbook(){[Name="CASH_FLOW_QUERY"]}[Content],
...
res = Record.HasFields(Source, "CashField"),
in
resSolved! Go to Solution.
@Anonymous your Source does not look like a record... Anyway, _after in_ instead of res write smth like
if Record.HasFields(your_test_record, "CashField") then name_of_the_last_step else [Ted_Striker_Says = "what a pisser"]. Power Query M is "lazy" so it starts from the end and won't execute subsequent steps if this field is missing.
@Anonymous your Source does not look like a record... Anyway, _after in_ instead of res write smth like
if Record.HasFields(your_test_record, "CashField") then name_of_the_last_step else [Ted_Striker_Says = "what a pisser"]. Power Query M is "lazy" so it starts from the end and won't execute subsequent steps if this field is missing.
I see, thank you! Before, i was trying something like: if Record.HasFields(your_test_record, "CashField") = False then <EXIT_QUERY> inside the LET statement... Sounds like my understanding of Power Query M was wrong!
@Anonymous order of lines of your code does not matter
let
res = if b = 2 then null else c,
a = 1,
c = a + b,
b = 2
in
res
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 14 | |
| 11 | |
| 8 | |
| 7 | |
| 6 |