PL-300 · Domain 2: Model the data · 27% of the exam
Task 2.2: Create model calculations by using DAX
Single aggregation measures, CALCULATE, time intelligence, basic statistical functions, semi-additive measures, quick measures, calculated tables and columns, and calculation groups.
Study it
Measures and CALCULATE
Lesson coming
Time intelligence and semi-additive measures
Lesson coming
Statistical functions, quick measures and calculation groups
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the Microsoft documentation page that proves it.
Question 1 · choose 1
Finance users connect to a semantic model with Analyze in Excel. In their PivotTables they can't get a total of the Sales[Amount] column, although report authors in Power BI sum it in visuals without trouble. What should you add to the model?
AA calculated column that repeats the total amount on every row
BAn explicit measure such as Total Amount = SUM(Sales[Amount])
CA hierarchy that includes the Amount column with Year and Month
DThe Sum default summarization on the Sales[Amount] column's properties
Show the answer and why
AA calculated column that repeats the total amount on every row
Incorrect
A calculated column is still a column, which MDX can't summarize.
BAn explicit measure such as Total Amount = SUM(Sales[Amount])
Correct
PivotTables send MDX queries, which can summarize explicit measures but not column values.
CA hierarchy that includes the Amount column with Year and Month
Incorrect
Hierarchies organize columns for drilling; they don't create a summarization for Excel.
DThe Sum default summarization on the Sales[Amount] column's properties
Incorrect
Default summarization creates implicit measures for Power BI visuals, which MDX clients don't use.
Columns that visuals summarize act as implicit measures, but MDX can't summarize column values. Because Analyze in Excel PivotTables issue MDX queries, a model used that way must include explicit measures, written in DAX, for the values users need to aggregate.
A matrix shows Sales by product, and the page has slicers for Year, Region and Product. A % of All Products measure must divide each product's sales by the sales of every product, even when the Product slicer selects only some, while still respecting the Year and Region slicers. Which denominator should the measure use?
ACALCULATE([Sales], ALL(Sales))
BCALCULATE([Sales], REMOVEFILTERS(Product))
CSUMX(Product, [Sales])
DSUM(Sales[Amount])
Show the answer and why
ACALCULATE([Sales], ALL(Sales))
Incorrect
Removing all filters from the Sales table also drops the Year and Region filters that reach it.
BCALCULATE([Sales], REMOVEFILTERS(Product))
Correct
It removes only the filters on Product, so year and region filters still apply to the total.
CSUMX(Product, [Sales])
Incorrect
This iterates only the products in the current filter, so it doesn't reach every product.
DSUM(Sales[Amount])
Incorrect
This uses the same filters as the numerator, so each row shows 100%.
In CALCULATE, REMOVEFILTERS, like ALL used as a filter modifier, clears filters from the tables or columns it names, so REMOVEFILTERS(Product) keeps the filters that come from other tables such as Date and Region. Clearing filters on the fact table removes the dimension filters that reach it as well.
A Margin % measure divides margin by sales. For some new products, sales are zero, and visuals should show nothing for them rather than an error or infinity. Which expression should the measure use?
A[Margin] / [Sales]
BIFERROR([Margin] / [Sales], 0)
C[Margin] / SUM(Sales[Amount])
DDIVIDE([Margin], [Sales])
Show the answer and why
A[Margin] / [Sales]
Incorrect
The divide operator returns infinity or an error when the denominator is zero.
BIFERROR([Margin] / [Sales], 0)
Incorrect
This shows 0 instead of nothing, and guidance discourages using error functions this way.
C[Margin] / SUM(Sales[Amount])
Incorrect
The denominator can still be zero, so the problem remains.
DDIVIDE([Margin], [Sales])
Correct
DIVIDE returns BLANK when the denominator is zero, unless you give it an alternate result.
The DIVIDE function handles division by zero: it returns BLANK, or an alternate result you provide, when the denominator is zero. The divide operator (/) doesn't, so guidance recommends DIVIDE when the denominator can be zero or BLANK, rather than wrapping the operator in error functions.
The company's fiscal year ends on June 30. The model has a marked Date table, and measures use the classic time intelligence functions with the date column syntax. Which two measures return fiscal year-to-date sales? (Choose TWO.)
DATESYTD with the same year-end date returns the fiscal year-to-date dates as a filter.
ETOTALQTD([Sales], 'Date'[Date])
Incorrect
This accumulates from the start of the quarter, not the fiscal year.
TOTALYTD and DATESYTD accept an optional year_end_date string literal, such as "6-30", when the date column syntax is used; the year part is ignored. Without it, the year ends on December 31. TOTALYTD is shorthand for CALCULATE with DATESYTD.
Sales has one row per order, and you need an Order Count measure. A colleague wrote COUNT(Sales[OrderID]). What does DAX guidance recommend instead, and why?
ACOUNTROWS(Sales), because it counts table rows and clearly states the intent
BDISTINCTCOUNT(Sales[OrderID]), because it ignores blank order IDs and duplicates
CCOUNTA(Sales[OrderID]), because it counts text and numbers
DSUMX(Sales, 1), because iterators are always faster
Show the answer and why
ACOUNTROWS(Sales), because it counts table rows and clearly states the intent
Correct
Guidance prefers COUNTROWS for counting rows: it's efficient and doesn't depend on a column's blanks.
BDISTINCTCOUNT(Sales[OrderID]), because it ignores blank order IDs and duplicates
Incorrect
DISTINCTCOUNT counts distinct values and does count one blank; it's meant for unique values, not rows.
CCOUNTA(Sales[OrderID]), because it counts text and numbers
Incorrect
COUNTA counts non-blank values of a column, so it has the same blank issue as COUNT.
DSUMX(Sales, 1), because iterators are always faster
Incorrect
It counts rows, but it isn't the recommended or simpler way to do so.
To count table rows, guidance recommends COUNTROWS over COUNT: it's more efficient, it doesn't consider BLANKs in any column, and the intention is clearer. COUNT and COUNTA count non-blank values in a column.
An analyst who doesn't write DAX wants a year-to-date quick measure in a model whose tables use DirectQuery against SQL Server. The time intelligence calculations don't appear in the Quick measures list, although other calculations do. Why?
AQuick measures for time intelligence are only available in the Power BI service
BThe analyst needs Build permission on the DirectQuery model
CTime intelligence quick measures can't be created in DirectQuery mode
DQuick measures need the model's Date table to be hidden
Show the answer and why
AQuick measures for time intelligence are only available in the Power BI service
Incorrect
Quick measures are created in Power BI Desktop, which the analyst is using.
BThe analyst needs Build permission on the DirectQuery model
Incorrect
The analyst is editing the model in Power BI Desktop; Build permission isn't the issue.
CTime intelligence quick measures can't be created in DirectQuery mode
Correct
Their DAX would translate into expensive source queries, so they're unavailable for DirectQuery.
DQuick measures need the model's Date table to be hidden
Incorrect
Hiding the Date table has no effect on which quick measures are offered.
Quick measures generate DAX for common calculations. They're available when you can modify the model, with some support for SSAS live connections. You can't create time intelligence quick measures in DirectQuery mode, because the functions they use have performance implications when translated into source queries.
A Customer Count measure must return how many different customers bought something in the current filter context. Sales has one row per order line with a CustomerID column. Which function should you use?
ACOUNT(Sales[CustomerID])
BCOUNTROWS(Sales)
CSUM(Sales[CustomerID])
DDISTINCTCOUNT(Sales[CustomerID])
Show the answer and why
ACOUNT(Sales[CustomerID])
Incorrect
This counts every non-blank line, so repeat buyers are counted many times.
BCOUNTROWS(Sales)
Incorrect
This counts order lines, not customers.
CSUM(Sales[CustomerID])
Incorrect
Adding ID numbers together doesn't count anything meaningful.
DDISTINCTCOUNT(Sales[CustomerID])
Correct
It counts each customer once, however many lines they have.
DISTINCTCOUNT counts the number of distinct values in a column. COUNT counts non-blank values, and COUNTROWS counts rows, so both count repeat customers more than once.
Which DAX function evaluates an expression, such as a measure, in a filter context that you modify with filter arguments?
AFILTER
BCALCULATE
CSUMX
DRELATED
Show the answer and why
AFILTER
Incorrect
FILTER returns a table of the rows that meet a condition; it doesn't evaluate a measure by itself.
BCALCULATE
Correct
CALCULATE evaluates its expression in a filter context modified by its filter arguments.
CSUMX
Incorrect
SUMX iterates a table and sums an expression for each row.
DRELATED
Incorrect
RELATED reads a column value; it doesn't evaluate an expression in a modified filter context.
CALCULATE evaluates an expression in a modified filter context. Its filter arguments can be Boolean filter expressions, table filter expressions or filter modifier functions.
A matrix shows Sales by month from a Date table. A Sales PM measure must show, on each month row, the sales of the month before. Which filter should the measure pass in CALCULATE([Sales], ...)?
APREVIOUSMONTH('Date'[Date])
BDATESMTD('Date'[Date])
CNEXTMONTH('Date'[Date])
DFIRSTDATE('Date'[Date])
Show the answer and why
APREVIOUSMONTH('Date'[Date])
Correct
It returns all dates of the previous month, based on the first date in the current context.
BDATESMTD('Date'[Date])
Incorrect
This returns the current month's dates up to the last date in context, not last month's dates.
CNEXTMONTH('Date'[Date])
Incorrect
This returns the dates of the following month.
DFIRSTDATE('Date'[Date])
Incorrect
This returns only the first date in the current context, which lies in the same month.
PREVIOUSMONTH returns a table that contains all dates from the previous month, based on the first date in the dates column in the current context: if the first date is June 10, it returns every date in May. Used as a CALCULATE filter, it gives each month row the previous month's value. NEXTMONTH works the same way for the following month.
Logistics wants the delivery time below which 90% of deliveries fall. Which DAX function returns that value from the DeliveryDays column?
AMEDIAN(Deliveries[DeliveryDays])
BMAX(Deliveries[DeliveryDays])
CSTDEV.S(Deliveries[DeliveryDays])
DPERCENTILE.INC(Deliveries[DeliveryDays], 0.9)
Show the answer and why
AMEDIAN(Deliveries[DeliveryDays])
Incorrect
The median is the 50th percentile.
BMAX(Deliveries[DeliveryDays])
Incorrect
The maximum is the 100th percentile.
CSTDEV.S(Deliveries[DeliveryDays])
Incorrect
A standard deviation isn't a percentile of the values.
DPERCENTILE.INC(Deliveries[DeliveryDays], 0.9)
Correct
It returns the 90th percentile of the column's values.
PERCENTILE.INC returns the k-th percentile of values in a column, where k is between 0 and 1 inclusive, so 0.9 gives the 90th percentile. MEDIAN returns the middle value and MAX the largest.