0% complete

Data Visualization using Power BI · Lesson 2 of 3

DAX Measures, Filter Context, and Time Intelligence

Write measures that respond correctly to report filters and compare values across time.

Lesson

1. Introduction

DAX measures are evaluated when a visual requests a value, using the filters active in that visual. Understanding filter context explains why the same measure can show different values by region, product, or date.

2. Understand the concept

CALCULATE evaluates an expression under modified filter context. A proper date table supports reliable time calculations. DIVIDE handles zero denominators more safely than the division operator; measures should match the business definition and be tested with slicers.

3. Syntax and interpretation

Total Sales = SUM(FactSales[SalesAmount])
Sales YTD = TOTALYTD([Total Sales], DimDate[Date])
Average Order = DIVIDE([Total Sales], [Orders])

Time intelligence depends on a correctly related date table and an agreed calendar or fiscal-year definition.

4. Apply it to an analysis

Write measures that respond correctly to report filters and compare values across time. Start with a small, known example and state what each row or value represents. After the transformation, check row counts, types, keys, and units against the original data. If an assumption fails, stop and investigate instead of presenting the output as a valid result.

5. Common mistakes

  • Using calculated columns when a filter-responsive measure is required.
  • Applying time calculations to an incomplete or incorrectly related date table.

6. Practice task

Write a measure for completed order revenue divided by distinct completed orders.

7. One possible solution

Completed Average Order = DIVIDE([Completed Sales], [Completed Orders]). Check that both measures use the same status definition.

8. Summary and next step

Write measures that respond correctly to report filters and compare values across time. Continue to the next course section and apply this foundation to a different analytics tool or workflow.

Visual guide

Working through DAX Measures, Filter Context, and Time Intelligence

  1. Step 01 Define

    State the question, data grain, and expected output.

  2. Step 02 Apply

    Use the method and check its assumptions on a small example.

  3. Step 03 Verify

    Reconcile the result and communicate limitations.

Code examples

Calculate sales for one status
TEXT
Completed Sales = CALCULATE([Total Sales], FactSales[Status] = \"Complete\")
Expected output
Calculates sales with the Complete status filter applied.
Compare with previous year
TEXT
Sales Previous Year = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(DimDate[Date]))
Expected output
Evaluates sales over the corresponding previous-year date period.

Key points

  • Write measures that respond correctly to report filters and compare values across time.
  • Check the result against the stated data definition and a representative example.
  • Record assumptions and report data-quality limitations rather than hiding them.

Check your understanding

Practice

Which approach best applies the ideas in DAX Measures, Filter Context, and Time Intelligence?

Your learning progress

Finish this lesson