Ravindra BagaleCourses & study guides

13. DAX: Data Analysis Expressions

13.3 Evaluation Context

To master DAX you must understand context (संदर्भ) – the environment in which a formula is calculated.

Row context

Mitrano, row context (ओळ संदर्भ – सध्या कोणत्या ओळीवर हिशोब चालू आहे) means "the current row". It exists automatically in calculated columns, and inside iterator (एकेक ओळ फिरून हिशोब करणारे फंक्शन) functions like SUMX, AVERAGEX and FILTER, which go through a table row by row.

In the calculated column Gross Line Value = Orders[Amount] + Orders[Discount], DAX knows which row's Amount to use karan of row context.

Row context does not filter

Row context alone does not filter other tables or aggregations (एकत्रीकरण). In a calculated column, SUM(Orders[Amount]) returns the grand total on every row, not the row's value.

Filter context

Filter context (गाळणी संदर्भ – सध्या कोणते फिल्टर लागू आहेत) is the set of filters applied to the data when a measure is calculated. It comes from:

  • rows/columns/axis of the visual (e.g. each bar for a City),
  • slicers and cross-highlighting from other visuals,
  • visual, page and report filters in the Filters pane,
  • row-level security (ओळ-स्तरीय सुरक्षा),
  • filter arguments inside CALCULATE.

He bagha: example: in a matrix with City on rows, the cell for "Pune" computes [Total Sales] with a filter DarkStore[City] = "Pune". The total row computes it with no City filter.

Context transition

When CALCULATE is used where a row context exists (for example inside a calculated column or an iterator), it turns the current row into an equivalent filter context. This is called context transition. Every measure reference is automatically wrapped in CALCULATE, which is why this works:

-- Calculated column in the Customer table
Customer Lifetime Sales = [Total Sales]

Each customer row gets only its own sales, karan the row context (current customer) becomes a filter on Customer.

Mitrano, ha DAX madhla sagalyat mahatvacha concept aahe. Samjla ka? Nasel tar punha ekda vacha – ghai karu naka.

Ravindra Bagale's Tip

A common mistake is testing a measure only in a card, where the only filters are the slicers. Put it in a table by City and Month to see how it changes with each row's filter context. If every row shows the same value, a relationship or filter is missing. It's very simple – just make it a habit.