If(cond, then, else)

If and nested If in Power BI

Qlik's If() maps directly to DAX IF and to Power Query's if ... then ... else. Long nested Ifs are cleaner as SWITCH(TRUE(), ...). Qlik's numeric booleans (-1/0) are the main difference.

Direct equivalent DAX Power Query

Short answer: Use IF for one condition and SWITCH(TRUE(), cond1, r1, cond2, r2, else) for nested ones. In Power Query, write if ... then ... else if ....

What it does in Qlik

If(condition, then [, else]) returns then when the condition is true and else otherwise. If else is omitted, it returns NULL. A condition is true when it evaluates to any non-zero number; Qlik's True() is -1.

Qlik example

Qlik script and chart
// script
If(Amount >= 10000, 'Large', If(Amount >= 1000, 'Medium', 'Small')) AS SizeBand

// chart
If(Sum(Sales) > Sum(Target), 'On track', 'Behind')

Power BI equivalent

Calculated column or measure (DAX)

DAX
Size band =
SWITCH (
    TRUE (),
    Sales[Amount] >= 10000, "Large",
    Sales[Amount] >= 1000, "Medium",
    "Small"
)

Status = IF ( [Sales] > [Target], "On track", "Behind" )

Power Query conditional column

Power Query M
= Table.AddColumn(Source, "SizeBand", each
    if [Amount] >= 10000 then "Large"
    else if [Amount] >= 1000 then "Medium"
    else "Small", type text)

Static bands like this are best done in Power Query (or in the source), where they compress well and are shared by all reports.

Gotchas and behaviour differences

  • Qlik booleans are numbers: Sum(Region = 'North') counts -1 per match. In DAX, TRUE() converts to 1, and in Power Query you need if ... then 1 else 0.
  • A blank amount: in Power Query null >= 1000 is null and the if raises an error, so test for null first. In DAX, BLANK compares as 0 and falls through to "Small".
  • If-based measures evaluated row by row inside large tables can be slow in both tools. Push static logic to columns.

Official documentation

Related pages

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.