MSBA-269 · Lesson 7 of 12 · 21 min
DAX questions
▶ Video coming soon A video version of this lesson is on the way.
Kwabena writes DAX every week, so he did not expect DAX questions to be a problem. Then Rupert handed him a printed page with six expressions on it, each with a blank, and a timer set for six minutes. He finished four. "You know DAX," Rupert said, "but the exam doesn't ask you to write DAX. It asks you to read DAX quickly, under pressure, with the wrong answers chosen because they look almost right. That is a different skill, and it improves with practice." The session became a reading drill.
This lesson works through the DAX objectives of domain 2 as they appear in exam questions. It assumes the material in Modeling Data and Writing DAX (MSBA-261). The examples use the Student Success model: a Registration fact table with Credits and StudentID columns, and Student, Program, Campus and Date dimensions. All the expressions are written for this course.
How DAX appears on the exam
DAX questions usually take one of four shapes. A completion item shows an expression with one or two dropdowns and asks you to choose the function or argument that meets a requirement. A prediction item shows an expression and a small table or visual and asks what result appears. A diagnosis item shows a measure that returns the wrong result and asks why. A choice item lists several measures and asks which one meets the requirement. In every case, reading speed and accuracy matter more than knowing obscure functions.
| Shape | What you see | Reading strategy |
|---|---|---|
| Completion | An expression with blanks | Read the requirement, then the whole expression with each option in place |
| Prediction | An expression and a context | Work out the filter context first, then the calculation |
| Diagnosis | A measure returning a wrong value | Look for context transition, ALL versus ALLSELECTED, or a missing date table |
| Choice | Several candidate measures | Eliminate those that ignore a stated filter or sum a semi-additive value |
Single aggregation measures
The simplest measures aggregate one column. The exam tests the difference between SUM, COUNT, COUNTROWS, DISTINCTCOUNT and AVERAGE. A requirement for "number of students" when a student can have many registrations needs DISTINCTCOUNT of StudentID, not COUNTROWS of Registration. Division should use DIVIDE, which returns blank (or an alternate result) instead of an error when the denominator is zero.
Students = DISTINCTCOUNT ( Registration[StudentID] )
Credits per Student =
DIVIDE ( SUM ( Registration[Credits] ), [Students] )CALCULATE and filter context
CALCULATE evaluates an expression in a modified filter context. Its filter arguments can add filters, replace filters on the same column, or remove them with REMOVEFILTERS or ALL. The exam returns to three ideas again and again. First, a simple filter argument such as Campus[Campus] = "Ridgeview" replaces any existing filter on that column. Second, KEEPFILTERS makes the new filter intersect with the existing one instead. Third, REMOVEFILTERS or ALL removes filters, and ALLSELECTED removes filters inside the visual while keeping those from slicers and the filter pane, which is the basis of "percent of visible total".
Ridgeview Credits =
CALCULATE ( SUM ( Registration[Credits] ), Campus[Campus] = "Ridgeview" )
Share of Visible Total =
DIVIDE (
SUM ( Registration[Credits] ),
CALCULATE ( SUM ( Registration[Credits] ), ALLSELECTED ( Program ) )
)Worked problem
A completion item
The deans want each program's credits as a percentage of all programs, ignoring the program rows of the matrix but respecting the Term and Campus slicers. Which function completes the denominator: CALCULATE ( SUM ( Registration[Credits] ), ____ ( Program ) )?
Show solution
- The denominator must remove the program filter coming from the matrix rows.
- It must keep filters from slicers (Term, Campus).
- ALL ( Program ) removes every filter on Program, including any program slicer, which may be wrong if a program slicer exists.
- ALLSELECTED ( Program ) removes the row-level filter but keeps the outer selections.
Answer: ALLSELECTED. If the question said "of all programs, even when a program slicer is used", ALL or REMOVEFILTERS would be the answer instead. The constraint words decide.
Time intelligence
Time intelligence functions such as TOTALYTD, DATESYTD, SAMEPERIODLASTYEAR, DATEADD and PARALLELPERIOD need a proper date table marked as a date table, related to the fact table. A diagnosis item often shows a year-to-date measure that returns the same value as the plain total; the usual causes are that the date table is not marked, the relationship uses a different date column, or the visual uses a date column from the fact table instead of the date table. For fiscal years, DATESYTD and TOTALYTD take a year-end date argument, such as "06-30" for a year ending June 30, which matters at an academic institution whose year does not end in December.
Credits YTD (Academic) =
CALCULATE (
SUM ( Registration[Credits] ),
DATESYTD ( 'Date'[Date], "06-30" )
)
Credits Prior Year =
CALCULATE ( SUM ( Registration[Credits] ), SAMEPERIODLASTYEAR ( 'Date'[Date] ) )Statistical and semi-additive measures
Basic statistical functions appear in requirements such as "median credits per student" or "standard deviation of course grades". Know that MEDIAN works on a column, and MEDIANX iterates a table expression, so median credits per student needs MEDIANX over a student list with a per-student sum. Semi-additive measures are for balances and headcounts that must not be summed across time. The usual pattern takes the last date in the current context: CALCULATE with LASTDATE, or with LASTNONBLANK when the last date may have no data.
Median Credits per Student =
MEDIANX ( VALUES ( Registration[StudentID] ), CALCULATE ( SUM ( Registration[Credits] ) ) )
Census Headcount =
CALCULATE (
SUM ( Census[Headcount] ),
LASTNONBLANK ( 'Date'[Date], CALCULATE ( SUM ( Census[Headcount] ) ) )
)The CALCULATE inside MEDIANX is a reminder of context transition: when a measure or CALCULATE is evaluated inside an iterator, the current row becomes a filter. Without it, SUM inside MEDIANX would return the grand total for every student. Diagnosis items love this mistake.
Calculation groups and visual calculations
Calculation groups appear in the outline as "Create calculation groups". A calculation group contains calculation items, each of which modifies whatever measure is in the visual through SELECTEDMEASURE. A question might describe ten measures that each need current, year-to-date and prior-year versions, and ask for the approach that avoids writing thirty measures: a calculation group with three items. Visual calculations, in domain 3, also use DAX but are defined on a visual's own data, with functions such as RUNNINGSUM and COLLAPSE; they do not appear in the model's field list.
Calculation item "YTD" =
CALCULATE ( SELECTEDMEASURE (), DATESYTD ( 'Date'[Date], "06-30" ) )
Calculation item "Prior year" =
CALCULATE ( SELECTEDMEASURE (), SAMEPERIODLASTYEAR ( 'Date'[Date] ) )DAX query view and user-defined functions
DAX query view in Desktop lets you write and run DAX queries, such as EVALUATE with SUMMARIZECOLUMNS, to test measures and inspect results without building visuals. The outline mentions it alongside Performance Analyzer for finding poorly performing measures. DAX user-defined functions became generally available in the June 2026 update; they are reusable functions defined in the model. The April 2026 outline does not list them, so treat them as useful background rather than an exam priority.
| Wrong-looking-right answer | Why it is wrong |
|---|---|
| COUNTROWS ( Registration ) for "number of students" | Counts registrations, not distinct students |
| ALL ( Program ) when slicers must be respected | Removes slicer filters on Program as well |
| SUM inside an iterator without CALCULATE | No context transition; every row gets the grand total |
| SUM of a balance across months | Balances are semi-additive; take the last date |
| A calculated column for a ratio that must respond to slicers | Columns are computed at refresh; use a measure |
| Time intelligence on the fact table's date column | Use the marked date table's column |
Iterators and row context
An iterator such as SUMX, AVERAGEX or COUNTX evaluates an expression once for each row of a table and then aggregates the results. Inside the iterator there is a row context, so a column reference means "the value in the current row". Iterators answer questions that a plain aggregation cannot, such as total tuition when tuition is credits multiplied by a rate that differs by program. A plain SUM of a precomputed column would also work, but it would store a column; the iterator computes the same total at query time.
Tuition =
SUMX (
Registration,
Registration[Credits] * RELATED ( Program[RatePerCredit] )
)Two details in this expression appear often on the exam. RELATED follows a relationship from the many side to the one side and returns a single value for the current row; it works here because each registration belongs to one program. RELATEDTABLE goes the other way, from the one side to the many side, and returns a table. A distractor that uses RELATED from the Program table to Registration would fail, because one program has many registrations.
Context transition
When a measure is used inside a row context, such as inside an iterator or a calculated column, CALCULATE turns the current row into an equivalent filter. This is context transition. It explains a classic diagnosis item: a calculated column on the Student table defined as [Total Credits] returns each student's own credits, because the measure is wrapped in an implicit CALCULATE, while a calculated column defined as SUM ( Registration[Credits] ) returns the grand total on every row, because a plain SUM has no filter from the current row.
| Calculated column on Student | Result on each row | Why |
|---|---|---|
| SUM ( Registration[Credits] ) | The same grand total on every row | No context transition; the row context does not filter Registration |
| [Total Credits] | That student's credits | A measure reference triggers context transition |
| CALCULATE ( SUM ( Registration[Credits] ) ) | That student's credits | CALCULATE triggers context transition explicitly |
Variables and DIVIDE
Variables make expressions easier to read and often faster, because a variable is evaluated once where it is defined. On the exam, a variable can change the meaning of an expression: a variable defined before CALCULATE keeps the value it had in the original context, even if CALCULATE later changes the filters. DIVIDE returns blank, or an alternative you supply, when the denominator is zero, while the slash operator returns an error or infinity. Questions that mention "avoid errors when there are no registrations" are pointing to DIVIDE.
Share of Campus =
VAR CampusCredits = [Total Credits]
VAR AllCredits =
CALCULATE ( [Total Credits], ALL ( Campus ) )
RETURN
DIVIDE ( CampusCredits, AllCredits )Worked problem
A prediction item
A table visual shows Campus and Share of Campus, with a slicer on Term set to Fall 2026. Ridgeview has 1,200 credits in Fall 2026, Lakeshore 1,800 and Downtown 3,000. What does Share of Campus show for Lakeshore?
Show solution
- CampusCredits for Lakeshore in Fall 2026 is 1,800.
- AllCredits removes the Campus filter but keeps the Term slicer: 1,200 plus 1,800 plus 3,000 is 6,000.
- 1,800 divided by 6,000 is 0.3.
Answer: 0.3, shown as 30 percent if the measure is formatted as a percentage. The Term slicer still applies because ALL removes filters only from Campus.
FILTER versus a Boolean filter
CALCULATE accepts simple Boolean filters such as Campus[Name] = "Ridgeview", which replace any existing filter on that column. FILTER over a whole table is more flexible but can be slower and can keep filters you meant to replace. KEEPFILTERS changes a Boolean filter so that it intersects with the existing filter instead of replacing it. Exam items sometimes offer all three; the right one depends on whether the requirement says "regardless of the selected campus" (replace) or "only within the selected campuses" (intersect).
| Filter argument | Effect on an existing Campus filter |
|---|---|
| Campus[Name] = "Ridgeview" | Replaces it: always Ridgeview |
| KEEPFILTERS ( Campus[Name] = "Ridgeview" ) | Intersects: Ridgeview only if it is already selected |
| FILTER ( ALL ( Campus ), Campus[Name] = "Ridgeview" ) | Replaces it, like the Boolean form |
| FILTER ( Campus, Campus[Name] = "Ridgeview" ) | Intersects, because the table argument keeps current filters |
A reading routine for DAX items
Kwabena's final routine for any DAX item had four steps, and he said them to himself as he read. First, what is the requirement in plain words, such as "share of the selected campuses" or "closing balance at month end"? Second, what filters reach the cell: slicers, rows, columns, page and report filters? Third, which part of the expression changes those filters, and does it replace, remove or intersect? Fourth, what does the outer function do with the result: sum it, divide it, or return the last value? Answering those four questions before looking at the options kept him from choosing an expression that looked familiar but answered a slightly different question. The routine takes about twenty seconds once it is habit, and it is the same routine whether the item is a completion, a prediction, a diagnosis or a choice.
Common mistakes
MistakeReading only the gap in a completion item.
InsteadRead the whole expression with each option in place, then check it against the requirement.
MistakeForgetting that a plain filter argument replaces existing filters on the column.
InsteadUse KEEPFILTERS when the new filter must intersect the existing one.
MistakeAssuming DATESYTD always ends on December 31.
InsteadPass a year-end argument for fiscal or academic years.
MistakeWriting separate year-to-date versions of many measures.
InsteadA calculation group applies the logic to every measure.
Summary and key terms
- DAX questions test reading, not writing: completion, prediction, diagnosis and choice items.
- Know DISTINCTCOUNT versus COUNTROWS and use DIVIDE for ratios.
- CALCULATE filters replace existing filters on a column; KEEPFILTERS intersects; ALL, REMOVEFILTERS and ALLSELECTED remove filters in different scopes.
- Time intelligence needs a marked date table; fiscal years use a year-end argument.
- Iterators need context transition; semi-additive measures take the last date; calculation groups apply logic to many measures.
- Filter context
- The set of filters in effect when a measure is evaluated.
- Context transition
- The conversion of the current row into filters when CALCULATE runs inside an iterator.
- ALLSELECTED
- A function that removes filters inside a visual while keeping outer selections such as slicers.
- KEEPFILTERS
- A modifier that makes a CALCULATE filter intersect with existing filters.
- DAX query view
- A Desktop view for writing and running DAX queries against the model.
- SELECTEDMEASURE
- The function a calculation item uses to refer to the measure in the visual.
Practice problems
Work each problem on paper first, then reveal the answer to check.
A year-to-date measure shows the same value as the total in every month. Name two likely causes.
Show answer
The date table is not marked, or the visual uses the fact table's date column instead of the date table.
Which function removes the matrix row filter but keeps slicer selections?
Show answer
ALLSELECTED.
Why does SUM inside MEDIANX need CALCULATE?
Show answer
To trigger context transition so each student gets their own total.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.