Test your understanding of key DAX concepts, syntax, and functions used in Power BI data modeling. This quiz covers context manipulation, calculations, time intelligence, filtering, and common DAX functions to help you assess and deepen your DAX skills.
Which DAX function should you use to calculate the total sales amount from the Sales[SalesAmount] column?
Explanation: The SUM function adds up all numeric values in a column, making it ideal for calculating total sales. SUMX, while similar, is used for evaluating expressions row by row. COUNT only counts the number of rows or items, not their numeric total. MIN returns the smallest value, not the total.
What is the primary difference between the SUM and SUMX functions in DAX when calculating totals?
Explanation: SUM only adds up the numbers within a single column, while SUMX can compute an expression for each row and then sum those results. SUM does not require a filter, nor does SUMX specifically find maximums. Both SUM and SUMX have similar behavior regarding blanks.
Which DAX function would you use to calculate year-to-date (YTD) sales totals?
Explanation: TOTALYTD is specifically designed for calculating cumulative totals from the start of the year up to a selected date. PARALLELPERIOD shifts time periods, FIRSTDATE finds the earliest date, and AVERAGE finds the mean value rather than a cumulative total.
If you want to change the filter context for a calculation, which DAX function would you typically use?
Explanation: CALCULATE allows you to modify or override the filter context of an expression, letting you adjust what data is considered. SWITCH is for multi-condition logic, NOW provides the current date and time, and RANKX is used for ranking values.
How can you calculate the percentage of total sales for each product using DAX?
Explanation: Calculating a percentage involves dividing the part by the whole, and DIVIDE is used for this safely in DAX. Multiplying does not yield a percentage, and subtraction also does not provide the correct proportion. COUNT simply tallies rows, not percentages.
Which combination of functions is typically used in DAX to calculate a 30-day moving average of sales?
Explanation: AVERAGEX computes an average over an expression, and DATESINPERIOD provides the required 30-day time window. COUNTROWS and VALUES would only return counts or distinct values. SUMMARIZE and MIN, as well as MIN and MAX, do not directly provide a moving average.
When you want to replace blank values in a DAX measure with zero, which function should you use?
Explanation: COALESCE returns the first non-blank value in a list, making it perfect for substituting blanks. RANK provides ordering, EARLIER is for iterators and row contexts, and MAXX finds maximum values across expressions, not for handling blanks.
What is the main functional distinction between the ALL and ALLEXCEPT functions in DAX?
Explanation: ALL completely removes filters from columns or tables, while ALLEXCEPT retains filters on specified columns. ALL does not keep filters, nor does ALLEXCEPT add new ones. Neither function aggregates or specifically groups or divides data.
If you want to filter Sales data for the year 2021 in DAX, which approach should you use?
Explanation: Using FILTER with the YEAR function filters the data to only include rows from 2021. MAX retrieves the single largest year, not the filtered set. RANKX is for ranking, not filtering, and SUMMARIZE creates a summary table rather than filtering by year.
Which DAX approach should you use to compute a running total of sales for each date?
Explanation: This combination allows you to recalculate the sum for all dates up to the current row, creating a running total. MAXX with VALUES is not suited for cumulative calculations, EARLIER with SUMX is more relevant for nested row contexts, and COUNTROWS simply gives a count.
How does the IF function in DAX operate when analyzing values such as Sales[SalesAmount]?
Explanation: The IF function checks a condition and outputs one result if true and another if false. It does not filter for positive numbers, sum totals, or generate distinct lists; those are handled by other DAX functions.
What is the main purpose of the EARLIER function in DAX?
Explanation: EARLIER allows access to a value from an outer row context when iterating through a table expression. It doesn’t return the earliest date or remove filters; DISTINCTCOUNT is used for counting distinct rows.
How can you calculate the first day of any month for a given date using DAX?
Explanation: This formula combines the year and month from a date, and sets the day to one, giving the first day of the month. MIN finds the earliest date in a column. NOW returns the current date and time, not related to the context. FIRSTNONBLANK finds the first non-blank value based on sort order, not always the first day.
Which DAX function would you use to assign a dynamic rank to products based on their total sales?
Explanation: RANKX is designed for ranking items in a table based on a value or expression such as total sales. ROW creates temporary single-row tables, COUNTAX counts non-blank values, and LASTDATE finds the latest date in a column.
How can you calculate the number of days between Sales[StartDate] and Sales[EndDate] in DAX?
Explanation: DATEDIFF computes the difference between two dates in units like days. Subtracting dates manually may give errors with non-sequential data. COUNTROWS counts rows, not date intervals. EARLIER is not relevant for direct date calculation.