Courseiva
Model the datamediumMultiple ChoiceObjective-mapped

PL-300 Model the data Practice Question

You have a Power BI model with a table named 'Orders' that contains columns: OrderID, CustomerID, OrderDate, and TotalAmount. You need to create a measure that calculates the total sales amount for orders placed in the last 30 days, but only for customers who have placed more than 5 orders in total. What is the most efficient DAX measure?

⚠ Common exam trap

Many candidates choose Option B because they think KEEPFILTERS can wrap a scalar boolean condition such as CALCULATE(COUNTROWS(...)) > 5. That is invalid; KEEPFILTERS expects a filter expression, not a boolean scalar. The correct approach uses SUMX with a single FILTER to apply both row-level conditions efficiently.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

TotalSalesLast30Days = SUMX(FILTER(Orders, Orders[OrderDate] > TODAY() - 30 && CALCULATE(COUNTROWS(Orders), ALLEXCEPT(Orders, Orders[CustomerID])) > 5), Orders[TotalAmount])

It iterates over filtered rows where both conditions are met using a single FILTER and SUMX, which is syntactically valid and more efficient than multiple FILTER iterators. Option B is invalid because KEEPFILTERS expects a filter expression, not a scalar boolean result from CALCULATE(...) > 5.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • TotalSalesLast30Days = CALCULATE(SUM(Orders[TotalAmount]), FILTER(Orders, Orders[OrderDate] > TODAY() - 30), FILTER(Orders, CALCULATE(COUNTROWS(Orders), ALLEXCEPT(Orders, Orders[CustomerID])) > 5))

    Why it's wrong here

    This approach uses two separate FILTER arguments inside CALCULATE, each iterating the entire Orders table. The second FILTER's expression, which calls CALCULATE with ALLEXCEPT, forces a context transition on every row, recomputing the customer's order count repeatedly; this is computationally expensive and can cause subtle row-context issues because the two FILTERs are evaluated independently and then combined with an implicit AND. Consequently, the measure may produce the correct result in small tables but performs poorly and is harder to debug.

  • TotalSalesLast30Days = CALCULATE(SUM(Orders[TotalAmount]), KEEPFILTERS(Orders[OrderDate] > TODAY() - 30), KEEPFILTERS(CALCULATE(COUNTROWS(Orders), ALLEXCEPT(Orders, Orders[CustomerID])) > 5))

    Why it's wrong here

    The expression tries to use KEEPFILTERS around a logical comparison that contains a nested CALCULATE, which is not a valid filter argument inside CALCULATE. In DAX, a filter passed to CALCULATE can be a table expression or a Boolean expression, but wrapping `CALCULATE(COUNTROWS(...), ALLEXCEPT(...)) > 5` in KEEPFILTERS does not make it a valid predicate; it produces a syntax or evaluation error. The correct pattern must use FILTER to iterate rows before evaluating the count, or use a separate measure with a calculated column.

  • TotalSalesLast30Days = SUMX(FILTER(Orders, Orders[OrderDate] > TODAY() - 30 && CALCULATE(COUNTROWS(Orders), ALLEXCEPT(Orders, Orders[CustomerID])) > 5), Orders[TotalAmount])

    Why this is correct

    This is the correct answer because it uses a single SUMX iterator over a FILTERed table, where the filter expression evaluates both conditions in one row context. Inside the filter, `CALCULATE(COUNTROWS(Orders), ALLEXCEPT(Orders, Orders[CustomerID]))` correctly counts all rows for the same customer, avoiding any interference from the date filter on the outer row, and the AND ensures only customers with more than five orders and a recent order date are included. SUMX then sums the TotalAmount across those qualifying rows, directly matching the requirement while remaining efficient and maintainable.

  • TotalSalesLast30Days = CALCULATE(SUM(Orders[TotalAmount]), DATESINPERIOD(Orders[OrderDate], TODAY(), -30, DAY))

    Why it's wrong here

    This measure filters only by a date window using DATESINPERIOD relative to TODAY(), producing a date range of the last 30 days. However, it completely omits the required customer-level condition—that the customer must have more than five orders within that same period—so it returns total sales for all customers, not just qualifying ones. Moreover, DATESINPERIOD shifts the range as a static period and does not dynamically filter per customer, so the measure fails the stated requirement.

About these practice questions

One of 217 original PL-300 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PL-300 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PL-300 exam.