Alt(Sales, 0)

Alt and Coalesce in Power BI

Qlik Coalesce() and DAX COALESCE() both return the first argument that isn't NULL or BLANK. Alt() is different: it returns the first argument that has a valid number representation, so Alt('abc', 0) returns 0. DAX has no single function that skips text that way. Power Query uses the ?? operator.

Partial / different approach DAX Power Query

Short answer: Translate Alt(x, 0) on numbers to COALESCE([x], 0) in DAX or [x] ?? 0 in M. Before you add a fallback to a measure, check whether showing 0 is what you want, because it makes empty rows appear.

What it does in Qlik

  • Alt(e1, e2, ..., else) returns the first argument with a valid number representation, and the last argument if none has one.
  • Coalesce(e1, e2, ...) returns the first non-NULL argument, whether it's text or a number. It's in Qlik Cloud and newer Qlik Sense client-managed releases.
  • Both work in the script and in charts.

Qlik example

Qlik script and chart
Alt(Discount, 0) AS Discount          // NULL or text -> 0
Alt(Date#(D, 'YYYY-MM-DD'), Date#(D, 'DD/MM/YYYY'))   // first format that parses
Coalesce(Nickname, FirstName, 'Unknown') AS DisplayName

Power BI equivalent

DAX

DAX
Sales (0 when empty) = COALESCE ( [Sales], 0 )

Display name =
COALESCE ( Customer[Nickname], Customer[FirstName], "Unknown" )

Power Query

Power Query M
// null-coalescing operator
= Table.AddColumn(Source, "Discount0", each [Discount] ?? 0, type number)

// Alt(Date#(...), Date#(...)) style: try one format, then another
= Table.AddColumn(Source, "D", each
    try Date.FromText([D], [Format = "yyyy-MM-dd"])
    otherwise try Date.FromText([D], [Format = "dd/MM/yyyy"])
    otherwise null, type date)

try ... otherwise is the real Power Query match for Alt's "first one that parses as a number" behaviour.

Gotchas and behaviour differences

  • No 1:1 for Alt on text. COALESCE returns "abc" where Alt would skip it. If a column mixes numbers and text, fix the type in Power Query with try Number.From(...) otherwise null.
  • COALESCE([Sales], 0) in a matrix makes every row in the cross join show 0, for example every product times every month, because the measure is never blank. Qlik hides those combinations when they have no data. Consider applying the fallback only inside an existing context, as in IF(NOT ISEMPTY(Sales), COALESCE(...)).
  • DAX ISBLANK on an empty string returns FALSE. COALESCE treats "" as a value, as Qlik Coalesce does. See null handling.

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.