Courseiva
Model the dataeasyMultiple ChoiceObjective-mapped

PL-300 Model the data Practice Question

A company has a Power BI semantic model with a table named 'Sales' that contains columns: OrderDate, ShipDate, Quantity, and Revenue. The company wants to create a measure that calculates the total revenue for orders shipped within 7 days of the order date. Which DAX expression should be used?

⚠ Common exam trap

A common mix-up: candidates assume direct date subtraction works the same in DAX as in Excel or SQL, but DAX treats date subtraction as a datetime operation, not a simple day count, leading to incorrect results or errors.

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

CALCULATE(SUM(Sales[Revenue]), DATEDIFF(Sales[OrderDate], Sales[ShipDate], DAY) <= 7)

Options A and C contain the same valid DAX expression: CALCULATE(SUM(Sales[Revenue]), DATEDIFF(Sales[OrderDate], Sales[ShipDate], DAY) <= 7). This expression correctly uses CALCULATE to modify the filter context, applying DATEDIFF to compute the day difference between OrderDate and ShipDate, and filtering for orders shipped within 7 days. Both are correct because they are identical. Option B uses SUMX with FILTER, but direct date subtraction (Sales[ShipDate] - Sales[OrderDate]) in DAX treats dates as serial numbers with time components, which can lead to inaccurate day counts and is not recommended. Option D also uses direct date subtraction in a filter argument, which is similarly incorrect. Therefore, A and C are correct.

Answer analysis

Option-by-option breakdown

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

  • CALCULATE(SUM(Sales[Revenue]), DATEDIFF(Sales[OrderDate], Sales[ShipDate], DAY) <= 7)

    Why this is correct

    This expression is syntactically and functionally identical to the other correct option, and its presence as a duplicate answer choice is a common exam design to test your ability to recognize a valid pattern when it appears more than once. The DATEDIFF function with DAY computes the number of day boundaries between the two dates, returning an integer that does not depend on any time portion, so the filter condition in CALCULATE correctly identifies all sales where the ship-date-to-order-date span is exactly seven days or less. Since CALCULATE applies its filter arguments as a row-level condition over the current filter context, the SUM of Revenue is computed only for that subset, yielding the desired total. Recognizing that this version is correct, despite being repeated, reinforces the key rule: use DATEDIFF for date-difference comparisons, not arithmetic subtraction on datetime columns.

  • SUMX(FILTER(Sales, Sales[ShipDate] - Sales[OrderDate] <= 7), Sales[Revenue])

    Why it's wrong here

    This iteration-based approach uses SUMX to compute revenue row-by-row after FILTER applies a predicate based on direct date subtraction. In DAX, subtracting two DATETIME values yields a duration that can include fractional days from time-of-day components, so an order placed at 14:00 and shipped at 15:00 six days later evaluates as approximately 6.04, which still passes the <=7 test, but a similar subtraction with different times could produce a value like 7.04 and incorrectly exclude an order that shipped on the seventh calendar day. Moreover, using SUMX when a simple aggregated filter is needed introduces unnecessary iterator overhead and obscures the intent; the CALCULATE with DATEDIFF is the more reliable and efficient pattern.

  • CALCULATE(SUM(Sales[Revenue]), DATEDIFF(Sales[OrderDate], Sales[ShipDate], DAY) <= 7)

    Why this is correct

    This correct expression first computes a whole-number count of day boundaries crossed between OrderDate and ShipDate using DATEDIFF with the DAY interval, which ignores any time-of-day information in the datetime values. The predicate DATEDIFF(...) <= 7 is then used as a filter condition inside CALCULATE, so the context is restricted to only those sales rows where the shipping duration is at most seven days. Because DATEDIFF returns an integer for the specified interval, the comparison is deterministic and consistent, and the SUM of Revenue in the first argument is correctly aggregated under that filtered context. This is the recommended approach because it explicitly states the day interval and avoids the pitfalls of implicit duration conversions.

  • CALCULATE(SUM(Sales[Revenue]), Sales[ShipDate] - Sales[OrderDate] <= 7)

    Why it's wrong here

    Placing the direct column subtraction Sales[ShipDate] - Sales[OrderDate] inside the CALCULATE filter argument is problematic because DAX interprets the subtraction of datetime columns as a duration in decimal days, not a whole number of days. For example, if OrderDate is 2019-01-01 08:00 and ShipDate is 2019-01-08 09:00, the difference is 7.04, which fails the <=7 predicate even though the order shipped on the seventh calendar day; conversely, a difference of 6.96 might pass but still represents an order that crossed seven day boundaries when times are considered. This behavior makes the logic dependent on the precise time components stored in the datetime values, leading to inconsistent and often incorrect results. The proper way to measure elapsed calendar days is DATEDIFF, which counts completed day intervals and provides a trustworthy integer for the comparison.

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.