DAX Evaluation Context in Practice
A practical guide to how row and filter context shape DAX results, how to control context with CALCULATE, and how to validate measures against source totals.
Two kinds of context
Two kinds of context
DAX results depend on evaluation context: the information that determines which rows a formula can use and how it evaluates them. Two important kinds are and . They are related, but they do different jobs: supplies values from a current row, while determines which rows are included in a calculation.
: evaluate one row at a time
A calculated column has a current row available. If a Sales table contains Quantity and UnitPrice, this expression calculates a line amount for each row:
Line Amount = Sales[Quantity] * Sales[UnitPrice]
An iterator such as SUMX can perform the multiplication row by row during a calculation, then add the results:
Sales Amount =
SUMX (
Sales,
Sales[Quantity] * Sales[UnitPrice]
)
Inside SUMX, each row supplies its own quantity and unit price. The iterator evaluates their product for that row before moving to the next one, then sums the products. This is useful when you need an expression evaluated for each row but do not need to store a separate calculated column.
By contrast, SUM ( Sales[Quantity] ) adds the values in one column. It does not create a current row for a custom expression such as quantity multiplied by unit price.
: determine which rows contribute
is the set of conditions affecting a calculation. It can come from visual rows and columns, slicers, report filters, relationships between tables, or filters written in DAX. For example, a can sum the sales amount:
Sales Amount = SUM ( Sales[Amount] )
If a visual groups this by Product[Category], each category filters the related sales rows. A date slicer or region filter can narrow those rows further. The formula remains the same, but its result may change from one visual cell to another because each cell has a different .
Relationships help filters reach the rows they should affect. A common model design relates dimension tables such as Product, Region, and Date to a fact table such as Sales. When interpreting a , ask both: Which rows are included by the current filters? and, if the formula evaluates an expression row by row, Which row supplies the current values? Do not assume that alone filters an aggregation in another table; that requires , discussed in the next section.
Changing and transitioning context
Change the filters deliberately
evaluates an expression under a modified . Its filters can add conditions, replace an existing filter on the same column, or remove filters with a modifier function. The important question is not just what filter a formula names, but how that filter interacts with the context already in effect.
Replacement or intersection
Suppose [Sales Amount] is a . This calculates sales for the West region:
West Sales =
CALCULATE (
[Sales Amount],
Region[RegionName] = "West"
)
Other applicable filters, such as date and product filters, remain in effect. But if the visual or report already filters Region[RegionName], the West condition replaces that existing filter on the same column. Thus the can return West sales even when the visual's current region selection is something else.
If the intention is to keep the existing selection and narrow it to West, use :
West Sales Within Selection =
CALCULATE (
[Sales Amount],
KEEPFILTERS ( Region[RegionName] = "West" )
)
Here the new condition intersects with the existing region filter. If the existing selection excludes West, the intersection contains no matching region. Replacement and intersection are different behaviors, so choose based on the intended meaning of the calculation.
Remove only the filter you intend to ignore
A share-of-sales can keep the current filters in its numerator while removing the region filter from its denominator:
Sales Share of All Regions =
DIVIDE (
[Sales Amount],
CALCULATE (
[Sales Amount],
REMOVEFILTERS ( Region[RegionName] )
)
)
The numerator reflects the current context. The denominator clears Region[RegionName], but retains other applicable filters, such as date and product. That makes the denominator a total across regions for the otherwise current selection. Removing filters from the entire Region table when only the region-name column needs clearing can make the denominator broader than intended.
: make the current row a filter
by itself does not automatically filter an aggregation in another table. performs , converting the current row into . For example, in a calculated column on Product:
Product Sales =
CALCULATE (
SUM ( Sales[Amount] )
)
turns the current product row into a filter. If the model relationship connects Product to Sales, that filter can propagate to sales, so the aggregation evaluates for the current product.
A model invoked inside transitions automatically. A raw aggregation generally needs when it must respond to the current row. This distinction helps guide the choice of calculation: use a calculated column for a value to store per row; use a for an aggregation that should respond dynamically to report filters.
Date tables and date filters
Let date filters reach the facts
A dedicated Date table provides consistent fields for filtering and grouping sales by day, month, quarter, or year. Its date column should contain unique, nonblank, uninterrupted dates spanning complete years. Relate Date[Date] to the appropriate date column in Sales, usually with a one-to-many relationship, so filters on the can reach the fact table. For classic DAX time-intelligence functions, mark the table as the model's .
A basic can respond to the date context supplied through that relationship:
Sales Amount = SUM ( Sales[Amount] )
For example, putting Date[Year] in a visual groups the by year. Each year filters the related dates and, through the relationship, the sales rows contributing to that year's result.
Check the effect of a fixed year filter
can also set a year explicitly:
Sales in 2025 =
CALCULATE (
[Sales Amount],
Date[Year] = 2025
)
This returns sales for calendar year 2025, subject to other filters. The fixed condition replaces an existing filter on Date[Year]. Consequently, if a visual is grouped by year, this may show 2025 sales even on a row labeled with a different year. Check whether that behavior is intended before using a fixed year filter in a visual.
Reconciling measures to source totals
Compare like with like
A DAX should be checked against an independent total from the source system. Before comparing the numbers, align the scope and business rules: use the same date range, transaction grain, currency, status rules, and treatment of adjustments. If any of these differ, the totals may differ for reasons unrelated to an error in the DAX calculation.
Compare at more than one level
Apply equivalent filters in the model and source system, then compare both the overall total and subtotals—for example, monthly or regional totals. A mismatch at a particular level can help narrow the investigation. Differences may point to missing or duplicated rows, mismatched relationships, date-boundary issues, or filters that replace or remove more context than intended.
Do not remove filters merely to force the DAX result to match the source. First identify the intended comparison context, then make both totals use the same scope. The goal is to explain a difference, not hide it.
Interpret visual totals in context
A visual total is evaluated in its own . It is not necessarily the sum of the values currently visible when the is non-additive or changes context. Therefore, a total that differs from the arithmetic sum of displayed rows is not, by itself, proof of an error. Check how the is evaluated at the total level, and reconcile it to a source total only after matching the relevant scope and rules.
: The process of comparing a DAX result with an independent source total after aligning the scope and rules used by both.