Let
Let(name, expr, body) · Logic & variables
Binds name to expr for use inside body — for readability and efficiency: the bound expression is computed once in the compiled SQL even if referenced repeatedly. Nest Lets for multiple bindings: Let(a, …, Let(b, …, body)). The SquareX equivalent of DAX VAR … RETURN.
Example
Section titled “Example”MarginPct := Let(rev, [Revenue], Divide(rev - Sum(Sales.Cost), rev))Good to know
Section titled “Good to know”- A binding named after a function is an error (SQX013); shadowing an outer
Letbinding is only a warning (SQXW01). - Measures using
Letopen as code in the editor — the template builder shows a read-only summary.