Power BI Intermediate Lesson 1: CALCULATE and Filter Context

Power BI Intermediate Lesson 1: CALCULATE and Filter Context 1

πŸ“Ž This article includes 3 downloadable practice files ↓

⏱ 2 min read

πŸ“˜ Power BI Intermediate Course Β· Lesson 1 of 10

Advertisement
In this article
  1. Replace vs keep
  2. Common mistakes
  3. Practice

Every number in a Power BI visual is a measure evaluated under a filter context: the row, column, slicer and page filters that apply to that cell. CALCULATE is the only function that changes that context.

Total Sales      = SUM ( Sales[Amount] )
Computers Sales  = CALCULATE ( [Total Sales], Products[Category] = "Computers" )
North FY26 Sales = CALCULATE ( [Total Sales], Customers[Region] = "North", 'Date'[FY] = "FY 2025-26" )

In the practice model: Total Sales β‚Ή2,80,94,576; Computers β‚Ή1,43,28,920; North in FY 2025-26 β‚Ή58,10,689.

Replace vs keep

A filter argument on a column replaces any existing filter on that column. Put West Sales = CALCULATE([Total Sales], Customers[Region] = "West") in a table filtered to North and it still shows West’s β‚Ή71,78,449.

KEEPFILTERS intersects instead: inside a North filter, “North AND West” is empty, so the result is blank. Use it when the measure should respect the user’s slicer.

πŸ’‘ Read CALCULATE as: “take the current filters, apply these changes, then calculate”. Most “wrong number” problems are a filter you didn’t know was there; check slicers, page filters and visual-level filters first.

Common mistakes

  • Filtering a measure: CALCULATE([Total Sales], [Total Sales] > 100000) doesn’t work; filter a column, or use FILTER over a table.
  • Calculated columns for everything: a column is computed once per row at refresh; a measure responds to filters. Totals and ratios belong in measures.

Practice

Import pbi-intermediate-model.xlsx into Power BI Desktop (free), create the relationships listed at the top of the .dax file, mark the Date table as a date table and add this lesson’s measures. Compare your card and table values with the lesson’s sheet in the expected-results file. Those numbers were worked out independently in Python from the same data, so a mismatch means a filter or relationship to check.

πŸ“Ž Practice files for this article

⬇ Download all 3 files (ZIP Β· 61 KB)

  • πŸ“—
    Practice model (Excel)Two years of sales (700 orders, FY 2024-25 and 2025-26) with Customers, Products, a full Date table, Targets and RegionUsers.
    ⬇ XLSX Β· 63 KB
  • πŸ“„
    Lesson 1 measures (.dax)Every measure from this lesson, ready to paste into Power BI Desktop.
    ⬇ DAX Β· 934 B
  • πŸ“—
    Expected resultsThe numbers your measures should show, one sheet per lesson.
    ⬇ XLSX Β· 11 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong