Topic 07 — DAX
Topic Seven

DAX — Data Analysis
Expressions

The formula language of Power BI. DAX lets you define calculations that go beyond what drag-and-drop can do — custom aggregations, comparisons across time, and logic that responds to the context of every visual on your report.

DAX is a collection of functions, operators, and constants that can be used in a formula to calculate and return one or more values.

Unlike Excel formulas that work on cell ranges, DAX works on entire columns and tables. Every DAX formula is aware of the filters and relationships active in your data model at the moment a visual renders.

D Data
A Analysis
X Expressions

You've Been Using DAX All Along

Every time you dragged a numeric field into a visual and Power BI showed a sum, count, or average — that was DAX. You just didn't write it. Power BI wrote it for you. This is called Implicit DAX.

What Power BI does automatically
When you drop a column into a visual's Values well, Power BI applies a default aggregation — usually SUM for numbers, COUNT for text. Behind the scenes it generates a DAX expression like SUM(Sales[Price]) without you typing anything.
Where implicit DAX stops working
The moment you need something beyond a simple aggregation — compare this year to last year, calculate a running total, create a ratio — Power BI can't generate that automatically. That's where you write explicit DAX.

How DAX is Built

Every DAX formula follows the same structure — a name, an equals sign, a function, and its arguments. Arguments reference tables and columns using a specific notation.

Total Sales = SUM(Sales[Price])
Sales LY = CALCULATE( SUM(Sales[Price]), DATEADD(Dates[Date], -1, YEAR))
Measure name
Function
Table name
Column name
Parameter / value

DAX syntax explained — how a formula is structured and where to write it.


Measure vs Calculated Column

DAX can produce two kinds of results. Understanding the difference is critical — choosing the wrong one leads to slow reports or incorrect numbers.

DAX Measure
A calculation that is evaluated at query time — it recalculates every time a filter changes, a slicer moves, or a visual renders.
Exists in the Fields pane with a calculator icon
No column added to the table
Result changes based on filter context
Best for aggregations, ratios, time comparisons
Total Price =
SUM(Sales[Price])
Calculated Column
A new column added to a table, calculated row-by-row when the data is loaded. The result is stored in the model like any other column.
Appears as a new column in the table
Calculated once at refresh, then stored
Cannot respond to filter context
Best for row-level logic, categories, labels
Full Name =
Products[cate1] & " - " &
Products[manfacture]

Measure vs Calculated Column — when to use each and what happens behind the scenes.


Time Intelligence

Time intelligence functions let you compare and accumulate data across time periods — this year vs last year, month-to-date, running totals. They require a proper Date table in your model.

Prerequisite: Time intelligence only works when your model has a dedicated Date table marked as a date table, with no gaps in the date range. Power BI can auto-generate one, or you can connect your own.
SAMEPERIODLASTYEAR()
Returns the same period from the previous year. A shortcut for the most common DATEADD(-1, YEAR) pattern.
Sales LY = CALCULATE( SUM(Sales[Price]), SAMEPERIODLASTYEAR(Dates[Date]) )
If time allows
TOTALMTD()
Calculates a cumulative total from the start of the current month to the last date in context — month-to-date running total.
Sales MTD = TOTALMTD( SUM(Sales[Price]), Dates[Date] )
If time allows
Image / video coming soon
© 2025 askfarouk.net · Ahmed Farouk Microsoft Certified Trainer · Doha, Qatar