DAX Formulas

Last Updated: 03 Sep, 2026

What Are DAX Formulas in Power BI?

A DAX formula is an expression built from DAX functions, operators, and Table[Column] references that defines a calculated column, calculated table, or measure. Every DAX formula starts with a name, an equals sign, and then the expression that produces the result.

Where DAX Formulas Are Used

The same DAX formula language works in Power BI Desktop (for calculated columns, tables, and measures) and in Excel’s Power Pivot add-in, since both run on the same underlying DAX engine.

Filter-Based DAX Formulas

A DAX filter formula typically wraps CALCULATE() around a base measure, adding or overriding filter conditions — for example, calculating sales only for a specific region regardless of what’s selected elsewhere on the report page.

Using a Slicer Value Inside a DAX Formula

SELECTEDVALUE() reads the single value currently selected in a slicer and returns it (or a fallback value if multiple items are selected), letting a measure or text box respond dynamically to a user’s slicer choice.

Writing More Complex DAX Formulas

Complex DAX formulas usually nest several functions together — for example, CALCULATE() wrapped around FILTER(), combined with time intelligence functions for a year-over-year comparison. Using VAR to name intermediate results makes formulas like this far easier to read and debug than nesting everything in one line.

How to Write a DAX Formula in Power BI

This tutorial walks through writing a filtered DAX formula in about 6 steps — starting from a basic SUM() measure and wrapping it in CALCULATE() to apply a specific filter condition.

Prerequisites

  • Power BI Desktop with a Sales-style table loaded
  • A basic measure already created, or willingness to create one in step 1

Steps

  • Create a base measure: Total Sales = SUM(Sales[Amount]).
  • Decide what to filter: Identify the condition you want, e.g. only the West region.
  • Wrap the base measure in CALCULATE: West Sales = CALCULATE([Total Sales], Sales[Region] = “West”).
  • Test the formula: Add both measures to a table visual and confirm West Sales is a subset of Total Sales.
  • Add a slicer-driven version if needed: Use SELECTEDVALUE(Sales[Region]) inside a formula to react to whatever the user picks in a slicer.
  • Format the result: Set number formatting (currency, decimals) on the new measure via the Modeling ribbon.

Common Errors & Troubleshooting

  • Filtered measure returns the same number as the unfiltered one — check that the filter condition inside CALCULATE actually matches values in the data (case and spelling matter).
  • SELECTEDVALUE returns blank — this happens when multiple slicer values are selected at once; supply a second argument as a fallback label.
  • Formula works in isolation but breaks inside a visual — check whether an existing page- or report-level filter is interacting unexpectedly with the formula’s own filter.