SUB LoadDim(vName) ... END SUB; CALL LoadDim('Customer');
SUB, CALL and $(Include) in Power BI
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.
What it does in Qlik
SUB name(params) ... END SUBdefines a reusable block, andCALL name(args)runs it.$(Include=file.qvs)and$(Must_Include=...)pull script text in from a file, often for shared connection strings, calendars or variable definitions.
Qlik example
$(Must_Include=lib://Shared/connections.qvs);
SUB LoadDim(vName)
[$(vName)]: LOAD * FROM [lib://QVD/Dim_$(vName).qvd] (qvd);
END SUB
CALL LoadDim('Customer');
CALL LoadDim('Product');Power BI equivalent
Custom function
// query "LoadDim"
(name as text) as table =>
let
Source = Lakehouse.Contents(null){[workspaceId = WsId]}[Data]{[lakehouseId = LhId]}[Data],
T = Source{[Id = "dim_" & Text.Lower(name), ItemKind = "Table"]}[Data]
in
T
// query "Customer"
= LoadDim("Customer")The Lakehouse navigation above is illustrative. Generate the real Source step with Get data, then turn the table name into the parameter.
Shared connection settings
Use Parameters (Manage parameters) for server names and paths in place of include files with connection strings. Deployment pipelines can set them per stage.
Gotchas and behaviour differences
- No 1:1 for Include. There's no file include in Power Query. When the same SUB appears in 20 Qlik apps, the right Power BI design is usually one shared semantic model or dataflow, not 20 copies of a function.
- Dynamic data sources built inside functions, such as concatenated file paths, can block scheduled refresh in the service. Keep the base path static or parameterised.
Official documentation
- Sub..end sub - script control statement (Qlik Help)
- Include - script variable (Qlik Help)
- Using custom functions (Microsoft Learn)
- Using parameters (Microsoft Learn)
- Power Query templates (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
SET vSales = Sum(Sales); LET vToday = Today();
Variables (SET, LET and $-expansion)
Qlik variables hold expressions, values and settings, and are expanded as text. Power BI splits these roles: measures for reusable logic, Power Query parameters for load settings, what-if and field parameters for user input, calculation groups for logic applied to many measures, and VAR inside DAX.
Partial / different approach
SET ErrorMode = 0; ... IF ScriptError > 0 THEN ...
ErrorMode and ScriptError
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.
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.