Menu

Understanding DAX Syntax and Operators

Understanding DAX Syntax and Operators

Basic DAX Syntax

A DAX expression commonly begins with a name followed by an equals sign and a formula.

For example:

Total Sales = SUM(Sales[SalesAmount])

Here:

  • Total Sales is the measure name.
  • SUM is a DAX function.
  • Sales[SalesAmount] refers to the SalesAmount column in the Sales table.

The expression calculates the sum of the SalesAmount column within the applicable calculation context.

Referencing Tables and Columns

DAX uses table and column references to access model data.

For example:

Sales[Quantity]

This refers to the Quantity column in the Sales table.

A measure can reference columns through functions such as SUM, AVERAGE, and COUNT.

For example:

Average Price = AVERAGE(Sales[UnitPrice])

This measure calculates the average value of UnitPrice for the current context.

Arithmetic Operators

DAX supports standard arithmetic operators.

Operator

Purpose

Example

+Addition10 + 5
-Subtraction10 - 5
*Multiplication10 * 5
/Division10 / 5
^Exponentiation2 ^ 3

For example, a calculated column can calculate the revenue for each transaction:

SalesAmount = Sales[Quantity] * Sales[UnitPrice]

If a transaction contains 2 units priced at ₹50,000 each, its SalesAmount will be ₹100,000.

Comparison and Logical Operators

DAX also supports comparison operators such as =, >, <, >=, and <=.

These are useful when defining conditions.

For example:

High Value Sale =

IF(Sales[SalesAmount] > 50000, "High", "Standard")

This expression labels transactions above ₹50,000 as High and all other transactions as Standard.

In this example, the expression is intended for a calculated column because it evaluates the condition for individual rows.


Power BI Tutorial

VA

Vishalini A



Learn via Video Course

Microsoft Power BI Logo

Microsoft Power BI

3 hrs



Get in Touch For Details