Bird
Raised Fist0
Power BIbi_tool~20 mins

CALCULATE function introduction in Power BI - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
CALCULATE Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ dax_lod_result
intermediate
2:00remaining
Calculate Total Sales for a Specific Year
Given a Sales table with columns [SalesAmount] and [Year], what is the result of this DAX measure?

TotalSales2019 = CALCULATE(SUM(Sales[SalesAmount]), Sales[Year] = 2019)

If the Sales table has these rows:
- Year: 2018, SalesAmount: 100
- Year: 2019, SalesAmount: 200
- Year: 2019, SalesAmount: 300
- Year: 2020, SalesAmount: 400

What is the value of TotalSales2019?
Power BI
TotalSales2019 = CALCULATE(SUM(Sales[SalesAmount]), Sales[Year] = 2019)
A500
B1000
C400
D300
Attempts:
2 left
💡 Hint
Think about filtering only the rows where Year is 2019 before summing.
❓ visualization
intermediate
2:00remaining
Visualizing Sales with CALCULATE Filter
You want to create a bar chart showing total sales only for the year 2020 using a measure with CALCULATE.

Which of these DAX measures will correctly show total sales for 2020 in the bar chart?
ATotalSales2020 = CALCULATE(SUM(Sales[SalesAmount]), FILTER(Sales, Sales[Year] <> 2020))
BTotalSales2020 = CALCULATE(SUM(Sales[SalesAmount]), Sales[Year] = 2020)
CTotalSales2020 = SUM(Sales[SalesAmount]) + Sales[Year] = 2020
DTotalSales2020 = CALCULATE(SUM(Sales[SalesAmount]), ALL(Sales[Year]))
Attempts:
2 left
💡 Hint
Remember CALCULATE changes the filter context to what you specify.
🧠 Conceptual
advanced
1:30remaining
Understanding CALCULATE Filter Context Modification
Which statement best describes what the CALCULATE function does in DAX?
AIt creates a new table with all rows from the original table.
BIt only sums numeric columns without any filtering.
CIt changes the filter context for the calculation by applying specified filters.
DIt removes all filters from the current report page.
Attempts:
2 left
💡 Hint
Think about how CALCULATE affects what data is included in a measure.
🔧 Formula Fix
advanced
1:30remaining
Identify the Error in CALCULATE Usage
What error will this DAX measure cause?

Measure = CALCULATE(SUM(Sales[Amount]), Sales[Year] == 2021)
Power BI
Measure = CALCULATE(SUM(Sales[Amount]), Sales[Year] == 2021)
ASyntax error due to double equals (==) instead of single equals (=)
BNo error, measure returns sum for year 2021
CType error because SUM cannot be used inside CALCULATE
DRuntime error because Sales[Year] column does not exist
Attempts:
2 left
💡 Hint
Check the filter condition syntax inside CALCULATE.
🎯 Scenario
expert
2:30remaining
Using CALCULATE to Override Existing Filters
You have a report page filtered to Year = 2022. You want a measure that shows total sales for Year = 2021 regardless of the page filter.

Which DAX measure achieves this?
ATotalSales2021 = CALCULATE(SUM(Sales[SalesAmount]), Sales[Year] = 2021)
BTotalSales2021 = CALCULATE(SUM(Sales[SalesAmount]), REMOVEFILTERS(Sales[Year]))
CTotalSales2021 = SUM(Sales[SalesAmount])
DTotalSales2021 = CALCULATE(SUM(Sales[SalesAmount]), ALL(Sales[Year]), Sales[Year] = 2021)
Attempts:
2 left
💡 Hint
Think about how to ignore existing filters on Year before applying your own filter.

Practice

(1/5)
1. What is the main purpose of the CALCULATE function in Power BI?
easy
A. To change the filters applied to a calculation and modify the result
B. To create a new table from existing data
C. To sort data in ascending or descending order
D. To connect two tables with a relationship

Solution

  1. Step 1: Understand the role of CALCULATE

    CALCULATE changes the filters applied to a calculation, allowing you to modify the context of the data used.
  2. Step 2: Compare with other options

    Creating tables, sorting data, or connecting tables are different functions; CALCULATE specifically changes filter context.
  3. Final Answer:

    To change the filters applied to a calculation and modify the result -> Option A
  4. Quick Check:

    CALCULATE changes filters = To change the filters applied to a calculation and modify the result [OK]
Hint: Remember CALCULATE changes filters to adjust results [OK]
Common Mistakes:
  • Confusing CALCULATE with table creation functions
  • Thinking CALCULATE sorts data
  • Assuming CALCULATE creates relationships
2. Which of the following is the correct syntax to calculate total sales for the year 2023 using CALCULATE?
easy
A. CALCULATE(SUM(Sales[Amount]), Sales[Year] == 2023)
B. CALCULATE(SUM(Sales[Amount]), FILTER(Sales, Sales[Year] == 2023))
C. CALCULATE(Sales[Amount], Sales[Year] = 2023)
D. CALCULATE(SUM(Sales[Amount]), Sales[Year] = 2023)

Solution

  1. Step 1: Understand CALCULATE syntax

    CALCULATE requires an expression and filter conditions. Simple filters use direct boolean expressions like Sales[Year] = 2023.
  2. Step 2: Analyze each option

    A correctly uses direct filter syntax. B uses FILTER but == is invalid in DAX. C misses SUM aggregation. D uses == which is invalid.
  3. Final Answer:

    CALCULATE(SUM(Sales[Amount]), Sales[Year] = 2023) -> Option D
  4. Quick Check:

    Direct Table[Column] = value filter in CALCULATE = CALCULATE(SUM(Sales[Amount]), Sales[Year] = 2023) [OK]
Hint: Direct column = value works as filter in CALCULATE [OK]
Common Mistakes:
  • Using double equals (==) instead of single equals (=)
  • Using FILTER with invalid operators like ==
  • Not aggregating the column inside CALCULATE
3. Given the following DAX measure:
Sales 2023 = CALCULATE(SUM(Sales[Amount]), Sales[Year] = 2023)

What will be the result if the Sales table has:
- 2022 sales: 1000
- 2023 sales: 1500
- 2024 sales: 2000

What does Sales 2023 return?
medium
A. Error due to syntax
B. 1500
C. 1000
D. 4500

Solution

  1. Step 1: Check the syntax of the measure

    The filter Sales[Year] = 2023 is valid direct boolean syntax in CALCULATE.
  2. Step 2: Determine the output

    It sums Sales[Amount] only for rows where Year = 2023, which totals 1500.
  3. Final Answer:

    1500 -> Option B
  4. Quick Check:

    Direct filter sums 2023 sales = 1500 [OK]
Hint: Direct filters in CALCULATE are valid and efficient [OK]
Common Mistakes:
  • Thinking direct filters require FILTER function
  • Miscalculating the filtered total
  • Confusing DAX filter syntax requirements
4. You wrote this measure:
Total Sales 2023 = CALCULATE(SUM(Sales[Amount]), Sales[Year] == 2023)

But it returns an error. What is the problem?
medium
A. Using double equals (==) instead of single equals (=) in filter condition
B. SUM cannot be used inside CALCULATE
C. Sales[Amount] column does not exist
D. CALCULATE cannot filter by year

Solution

  1. Step 1: Identify the syntax error in filter condition

    DAX uses single equals (=) for comparisons, not double equals (==) like some programming languages.
  2. Step 2: Confirm other parts are correct

    SUM inside CALCULATE is valid, Sales[Amount] assumed correct, and filtering by year is allowed.
  3. Final Answer:

    Using double equals (==) instead of single equals (=) in filter condition -> Option A
  4. Quick Check:

    Use single equals in DAX filters = Using double equals (==) instead of single equals (=) in filter condition [OK]
Hint: Use single = for comparisons in DAX filters [OK]
Common Mistakes:
  • Using == instead of = in filter expressions
  • Thinking SUM can't be inside CALCULATE
  • Assuming CALCULATE can't filter columns
5. You want to create a measure that calculates total sales for the product category "Bikes" in 2023. Which of the following DAX formulas correctly uses CALCULATE to achieve this?
hard
A. CALCULATE(SUM(Sales[Amount]), FILTER(Sales, Sales[Year] == 2023 && Sales[Category] == "Bikes"))
B. CALCULATE(SUM(Sales[Amount]), FILTER(Sales, Sales[Year] == 2023 && Sales[Category] = "Bikes"))
C. CALCULATE(SUM(Sales[Amount]), Sales[Year] = 2023, Sales[Category] = "Bikes")
D. CALCULATE(SUM(Sales[Amount]), Sales[Year] == 2023 && Sales[Category] == "Bikes")

Solution

  1. Step 1: Understand filter syntax in CALCULATE

    CALCULATE accepts multiple filter arguments as boolean expressions using single equals (=), separated by commas.
  2. Step 2: Evaluate each option

    A uses == invalid. B correctly uses multiple direct filters. C uses FILTER with == invalid. D uses == and && without proper structure invalid.
  3. Final Answer:

    CALCULATE(SUM(Sales[Amount]), Sales[Year] = 2023, Sales[Category] = "Bikes") -> Option C
  4. Quick Check:

    Multiple direct filters Sales[Year]=2023, Sales[Category]="Bikes" [OK]
Hint: Multiple boolean filters separated by commas in CALCULATE [OK]
Common Mistakes:
  • Using double equals (==) in DAX filters
  • Using && directly in CALCULATE without FILTER
  • Confusing syntax with other programming languages
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard