13. DAX: Data Analysis Expressions
13.4 DAX Syntax
Measure Name = FUNCTION( Table[Column], argument2, ... )
- Measure/column name, then
=, then the expression. - Table names with spaces or reserved words need single quotes:
'Date'[Year]. (We always quote'Date'because Date is also a function name.) - Columns are always in square brackets:
Orders[Quantity]. - Text strings in double quotes:
"Blinkit". - Comments:
--or//for one line,/* … */for multiple lines. - Use Shift + Enter for a new line in the formula bar; indent for readability.
- DAX is not case-sensitive for function names, but consistent style helps.
Data types in DAX
Whole number (Int64), Decimal number, Currency (fixed decimal), Date/time, Boolean (TRUE/FALSE), String, and BLANK (DAX's version of null). Most arithmetic treats BLANK as 0, while visuals hide rows where all measures are blank.
Operators
| Type | Operator | Example |
|---|---|---|
| Arithmetic | + - * / ^ |
Orders[Quantity] * RELATED(Product[Unit Price]) |
| Comparison | = == <> > >= < <= |
Orders[Delivery Time Mins] <= 10 |
| Text concatenation | & |
DarkStore[Area] & ", " & DarkStore[City] |
| Logical | && (AND), || (OR), NOT() |
Orders[Platform] = "Blinkit" && Orders[Quantity] > 5 |
| List membership | IN { } |
DarkStore[City] IN { "Pune", "Nashik" } |
= treats BLANK as equal to 0 or empty string; == is a strict equality where BLANK only equals BLANK.
Ravindra Bagale's Tip
Syntax madhli ek common chuk mhanje referring to a measure with a table prefix (Orders[Total Sales]) or a column without one. Use Table[Column] for columns and [Measure] for measures. It makes formulas readable and avoids ambiguity. Samjla ka?