SET ErrorMode = 0; ... IF ScriptError > 0 THEN ...
ErrorMode and ScriptError in Power BI
SET ErrorMode = 0 makes the Qlik script carry on after an error, and ScriptError lets you branch on it. Power Query handles errors at the value or step level. try ... otherwise replaces one failing expression, and Replace, Remove or Keep errors work on columns. A query with an unhandled error fails the whole refresh. There is no "continue the rest of the script" mode. To orchestrate around failures, use a Fabric pipeline.
Short answer: Wrap risky sources as try Source otherwise #table(...) to return an empty table with the same columns. Use Keep errors to inspect bad rows. Turn on refresh failure notifications in the service.
What it does in Qlik
ErrorMode1 (the default) stops on errors and 0 ignores them.ScriptErrorholds the code of the last error,ScriptErrorCountthe count andScriptErrorListthe list.- A common pattern is trying to load a file, then loading a fallback if it's missing.
Qlik example
SET ErrorMode = 0;
Budget: LOAD * FROM [lib://Data/budget_2026.xlsx] (ooxml, embedded labels);
IF ScriptError > 0 THEN
TRACE Budget file missing - loading empty table;
Budget: LOAD * INLINE [Account, Amount];
END IF
SET ErrorMode = 1;Power BI equivalent
Power Query
let
Empty = #table(type table [Account = text, Amount = number], {}),
Budget = try Excel.Workbook(File.Contents("C:\Data\budget_2026.xlsx"), true){[Item = "Sheet1", Kind = "Sheet"]}[Data]
otherwise Empty
in
Budget
// value-level: bad numbers become null instead of errors
= Table.TransformColumns(Src, {{"Amount", each try Number.From(_) otherwise null, type nullable number}})Gotchas and behaviour differences
- Errors in individual cells don't fail the refresh by default. The values just become errors and load as blanks, with a warning in Desktop. Use Keep errors on a copy of the query to find them.
try ... otherwisearound a whole source hides real outages too. Log it, for example by adding a "Loaded from fallback" column, so a missing file doesn't go unnoticed.
Official documentation
- ErrorMode - error variable (Qlik Help)
- ScriptError - error variable (Qlik Help)
- Error handling (Power Query M) (Microsoft Learn)
- Dealing with errors in Power Query (Microsoft Learn)
Related pages
FOR EACH vFile IN FileList('lib://Data/*.csv') ... NEXT
FOR ... NEXT and FOR EACH loops
Power Query has no loop statement. It's a functional language. Loop over a list instead. List.Transform covers "do this for each item". List.Generate covers while-style loops. A custom function invoked per row of a table covers "load each file/table/month". Looping over files is built in as the Folder connector with Combine files.
Partial / different approach
SUB LoadDim(vName) ... END SUB; CALL LoadDim('Customer');
SUB, CALL and $(Include)
A SUB in Qlik maps to a custom function in Power Query, (param) => ..., invoked like any function. $(Include=...), which shares script files across apps, has no direct equivalent in Power BI Desktop. The closest options are shared dataflows, which centralise the transformation itself, Power Query templates (.pqt), or copy-pasting functions, which is honest but manual.
Partial / different approach
Null(), IsNull(), NullAsValue
NULL handling vs DAX BLANK and M null
Qlik NULL, DAX BLANK and Power Query null follow different arithmetic and comparison rules. This is one of the most common reasons migrated numbers do not reconcile.
Partial / different approach
Spotted an error or a better pattern? QlikToDax is maintained by a working BI consultant; corrections are welcome via the About page. Last reviewed 2026-10-25.