Ravindra BagaleCourses & study guides Track your progress

Labs · Power BI

Lab: Explain Your CALCULATE Measure and Filter Context Aloud in 2 Minutes

Intermediate30 minPower BI Desktop (free) · Your Lab D file (Mumbai Sales) · Phone voice recorder

Course: Power BI · Chapter 30: Interview Questions and Answers

Chapter 30 lists interview questions and answers; this lab trains you to say the most-asked DAX answer clearly.

Download city_sales.csv (12 rows)

Chala mitrano! "Explain CALCULATE" is asked in almost every Power BI interview. Many students know it but say it badly: too fast, too vague, no example. Today we practise saying it with your own measure, your own numbers, in 2 minutes. Record, listen, improve. Bolayla shika, nokri milva!

Suppose we are…

Suppose we are in a technical interview at TCS for a Power BI developer role. The interviewer says: "You wrote CALCULATE in your project. Explain what it does and what filter context means. Two minutes." We will answer using the Mumbai Sales measure from Lab D and the 12-row city_sales.csv. The numbers are sample data made up for practice.

Goal of this lab

By the end you will have:

  • A 5-part answer written on one card (or one phone note).
  • A 2-minute recording of yourself.
  • A score out of 10 from the checklist, and one improved second recording.

What you need (all free)

  • Power BI Desktop with Lab-D-calculate-mumbai.pbix from Lab D open (the card shows 147K and the city table shows 147,000 on every row). No file? Download city_sales.csv (12 rows) and do Lab D first.
  • A phone voice recorder.
  • 30 minutes.

The data: before and after

Before. The usual weak answer: "CALCULATE adds a filter", which cannot explain why the Pune row shows Mumbai's 147,000.

Before: city table with Total Sales 147,000, 131,000, 87,000 and Mumbai Sales 147,000 on every row; the common wrong answer says CALCULATE adds Mumbai to the row

After. The strong answer, in 3 steps per row: read the row's filter, CALCULATE replaces the City filter, then evaluate.

After: for each row, the filter from the row (City = Mumbai, Pune or Nagpur) is changed by CALCULATE to City = Mumbai, result 147,000

The formula

Your two measures from Lab D:

Total Sales = SUM ( city_sales[Sales] )
Mumbai Sales = CALCULATE ( [Total Sales], city_sales[City] = "Mumbai" )

The 5-part answer (about 2 minutes):

  1. Definition (15 s): "CALCULATE evaluates an expression in a modified filter context."
  2. Filter context (20 s): "Filter context is the set of filters active when a measure is calculated: from the visual's row, slicers, the filter pane and relationships."
  3. My example (30 s): "I wrote Mumbai Sales = CALCULATE of Total Sales with City = Mumbai. In a card with no filters, it shows 147,000."
  4. The tricky row (30 s): "In a table by City, the Pune row has the filter City = Pune. CALCULATE replaces the filter on the City column with City = Mumbai, so the Pune row shows 147,000. In a table by Product, the row filter is on Product, so CALCULATE keeps it and adds City = Mumbai: Mobile in Mumbai = 78,000."
  5. When to use it (15 s): "Whenever a number needs a filter different from the visual's: a fixed city, last year (with time intelligence), or all cities for a percentage (with ALL)."

Steps

  1. Open your Lab D file. Look at the card (147K), the city table and the product table. Write down 147,000, 131,000, 87,000 and 78,000 on a card.
  2. Write the 5 parts above in your own words, one line each. Keep the numbers.
  3. Practise once aloud while pointing at the screen (the city table for part 4).
  4. Open your phone's voice recorder. Record your answer, aiming for 1 minute 45 seconds to 2 minutes 15 seconds.

    What you should see: a recording between about 1:45 and 2:15. Under 1:00 usually means something important was skipped.

  5. Play it back and score it with the checklist below (1 point each).

  6. Fix the weakest two points and record a second time.

    What you should see: a higher score on the second recording. Keep the better one; listen to it again before a real interview.

Ravindra Bagale's Tip

The magic word is "replaces". Say it slowly: "CALCULATE replaces the filter on the same column". That one word explains the Pune row, and interviewers wait for it. Then say "and keeps filters on other columns": that explains the product table. Replace, keep: don shabda, poorna uttar!

Common mistakes

Mistake What happens Fix
"CALCULATE adds a filter" only Cannot explain the Pune row; sounds memorised Say replaces (same column) and keeps (other columns)
No example The answer sounds like a textbook Use your own measure and the number 147,000
Talking for 5 minutes The interviewer interrupts 5 parts, about 2 minutes
Mixing up row context and filter context Follow-up questions go badly Filter context = filters on the calculation; row context = "current row" in calculated columns and iterators
Reading from notes Sounds unsure Practise until you need only the 5 headings

Self-check checklist

Score your recording, 1 point each:

0 of 10 done

Try-at-home challenge

Interviewers often follow up: "How would you make Mumbai Sales respect a City slicer instead of replacing it, so it shows Mumbai only when Mumbai is selected and blank otherwise?" Prepare a 30-second answer with the formula.

Check your answer
Mumbai Sales (respect) = CALCULATE ( [Total Sales], KEEPFILTERS ( city_sales[City] = "Mumbai" ) )

"KEEPFILTERS makes CALCULATE intersect with the existing filter instead of replacing it. On the Mumbai row it is still 147,000; on the Pune row, Pune ∩ Mumbai is empty, so it is blank. With no city filter, it is 147,000." Say the word intersect.

Samjla ka? Define, explain filter context, show your measure, explain "replaces" and "keeps", give a use. Aata pudhe jaauya: solve 5 interview-style DAX tasks and check the answers.