Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS MATH

Power BI DAX Row and Filter Context


Share

One Measure, Many Answers

You have already written measures such as Total Sales.

Before you learn CALCULATE and the other advanced DAX functions, you need one key idea: context.

A measure does not have one fixed result.

Power BI calculates it again for every cell of every visual, and each cell sees a different part of the data.

The filters that decide which part of the data a cell sees are called the filter context.

This page uses the Poke Mart model described in DAX Introduction, with the Amount column from DAX RELATED and the Total Sales measure from DAX Measures.

As in the rest of the DAX chapter, amounts are formatted as Whole number with a thousands separator, and percentages as Percentage with 2 decimal places.


Total Sales in a Card

Add a Card visual and put the Total Sales measure in it.

The card shows one number, shortened to millions: 9M. The exact value is:

VisualTotal Sales
Card9,416,800

No filters apply to the card.

Total Sales adds up the Amount of all 2,740 orders.


Total Sales in a Matrix

Now put the same measure in a matrix:

  1. Click an empty spot on the canvas.
  2. In the Visualizations pane, select the Matrix visual.
  3. From the Stores table, drag Region to Rows.
  4. From the Date table, drag Year to Columns.
  5. From the Sales table, drag the Total Sales measure to Values.

A card with Total Sales next to a matrix of Total Sales with Region in Rows and Year in Columns, and the Rows, Columns and Values wells in the Visualizations pane

Region20242025Total
Hoenn1,324,7001,647,3002,972,000
Johto1,612,4501,751,2003,363,650
Kanto1,456,0501,625,1003,081,150
Total4,393,2005,023,6009,416,800

It is the same measure, with the same formula, SUM(Sales[Amount]).

But now it returns 12 different numbers.

Look at the cell for Johto in 2025: 1,751,200.

To get that number, Power BI:

  1. Filters the Stores table to Region = "Johto"
  2. Filters the Date table to Year = 2025
  3. Follows the relationships, so the Sales table keeps only the orders from Johto stores in 2025
  4. Calculates SUM(Sales[Amount]) over those rows

The two filters, Region = "Johto" and Year = 2025, are the filter context of that cell.

Totals Have Fewer Filters

The totals work the same way, with fewer filters:

CellFilter contextTotal Sales
Johto, 2025Region = Johto, Year = 20251,751,200
Johto, TotalRegion = Johto3,363,650
Total, 2025Year = 20255,023,600
Total, TotalNo filters9,416,800

The grand total has no filters, just like the card.

That is why both show 9,416,800.

Note: Power BI does not add up the cells above a total.

It calculates the measure again, with fewer filters.

For Total Sales the result is the same.

For a measure like Margin % or Avg Order Value, adding up the cells would give a wrong answer, but calculating again gives the right one.

This is also why the Total row of Big Store Sales on the IF and SWITCH page shows 9,416,800.



Where Filter Context Comes From

Filters can come from many places at once.

Power BI combines all of them for every cell:

SourceExample
Rows of a visualRegion in the Rows of the matrix
Columns of a visualYear in the Columns of the matrix
Axis or legend of a chartCategory on the X-axis of a column chart
SlicersA Category slicer with Balls selected
Filters paneA filter on one visual, on the whole page, or on all pages
Other visualsSelecting a column in a chart filters the other visuals on the page
The formulaCALCULATE, on the next page

Filters flow along the relationships, from the lookup tables (Stores, Products and Date) to the Sales table.

This is why the star schema matters: one filter on a Region filters all the orders of that region.

Example: Add a Slicer

Add a Slicer with Category from the Products table, and select Balls.

Every cell of the matrix gets one more filter, Category = "Balls":

Region (Balls only)20242025Total
Hoenn688,600790,8001,479,400
Johto770,200877,4001,647,600
Kanto624,800695,4001,320,200
Total2,083,6002,363,6004,447,200

The Johto 2025 cell now has three filters: Region = Johto, Year = 2025 and Category = Balls. The result is 877,400.

The card changes too.

It has one filter now, Category = Balls, so Total Sales is 4,447,200. The card shortens it to 4M.

Select Balls again to clear the slicer.


Row Context

The other kind of context is row context.

It means "the current row".

You met it in Calculated Columns and RELATED.

When you created the Amount column in the Sales table, Power BI calculated the formula once for each row:

Example

Amount = Sales[Quantity] * RELATED(Products[UnitPrice])

In Table view, the first rows of the Sales table look like this (some columns not shown):

123OrderIDABCProductID123Quantity123Amount
1001P0611,200
1002P01193,800
1003P02137,800
1004P089900
1005P04195,700
............

For order 1002, the current row has Quantity 19 and ProductID P01. RELATED follows the relationship to the Products table and returns the UnitPrice of P01, which is 200. The result is 19 * 200 = 3,800.

The values of a calculated column are calculated when the data is loaded or refreshed, and then stored in the table.

A slicer does not change them.

A measure is different: it is calculated each time a visual needs it, in the filter context of each cell.

Row Context vs Filter Context

Row contextFilter context
What it isThe current row of a tableThe filters that apply to one cell of a visual
Where you meet itCalculated columns, and inside iterator functions like SUMXMeasures in visuals
Created byGoing through a table one row at a timeRows, columns, slicers, filters, other visuals, and CALCULATE
ExampleAmount of order 1002 = 3,800Total Sales of Johto in 2025 = 1,751,200

A Measure Has No Current Row

A measure works on many rows at once, so it has no current row.

If you write a measure such as Test = Sales[Quantity], Power BI shows an error: it cannot pick one value from a column with 2,740 values.

A measure must aggregate a column, for example SUM(Sales[Quantity]).

Iterator functions like SUMX are the exception: they create a row context inside a measure.

You will learn them in SUMX and Iterators.


What You Learned

  • A measure is calculated again for every cell of a visual, in that cell's filter context.
  • Filter context comes from rows, columns, slicers, the Filters pane, other visuals, and the formula itself.
  • Filters flow from the lookup tables to the Sales table along the relationships.
  • Totals are calculated again with fewer filters, not added up.
  • Row context is the current row, in calculated columns and inside iterators.

On the next page, you will change the filter context yourself, with CALCULATE.



Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.