10 important DAX interview questions
Basic DAX Questions
1. What is DAX, and why is it important in Power BI?
DAX stands for Data Analysis Expressions—it's the formula language used in Power BI to create custom calculations and aggregations. It’s essential for building advanced analytics beyond simple visualizations.
2. What is the difference between a calculated column and a measure in DAX?
A calculated column is row-based and stored in the dataset, while a measure is dynamic and recalculates based on filters in your report. Measures are more memory-efficient for large datasets.
3. Explain the CALCULATE function and how it modifies filter context.
CALCULATE is one of the most powerful DAX functions! It allows you to modify filter context by applying new conditions. Example:
👉 CALCULATE(SUM(Sales[Revenue]), Sales[Region] = "East")
This filters data to only include sales from the East region.
4. How does the FILTER function work in DAX? Provide an example.
FILTER returns a subset of a table based on a condition. Example:
👉 FILTER(Sales, Sales[Amount] > 5000)
This filters the Sales table to only include transactions greater than 5,000.
5. What are row context and filter context in DAX? How do they impact calculations?
Row context applies when calculations operate on a single row, like in calculated columns.
Filter context applies when filters modify the data shown in a report, impacting measures. Understanding both is crucial for writing effective DAX!
Advanced DAX Questions
6. How does the ALL function work, and when should you use it?
The ALL function removes filters from a column or table. It’s useful when calculating percentages or totals. Example:
👉 ALL(Sales[Region])
removes region-based filters to show global totals.
7. What is the difference between EARLIER and VAR in DAX?
EARLIER is used in row context to refer to an earlier row in a calculation, but it’s complex. VAR is a more efficient way to store values and reuse them within a formula.
8. Explain time intelligence functions like TOTALYTD and SAMEPERIODLASTYEAR.
TOTALYTD calculates Year-to-Date totals:
👉 TOTALYTD(SUM(Sales[Revenue]), Date[Date])
SAMEPERIODLASTYEAR compares data from the same period in the previous year:
👉 SAMEPERIODLASTYEAR(Date[Date])
9. How do you handle many-to-many relationships using DAX?
Many-to-many relationships can be resolved using bridge tables or DAX functions like TREATAS to control filtering between tables.
10. What is the difference between SUMX and SUM? In what scenarios would you use each?
SUM adds up a column’s values:
👉 SUM(Sales[Amount])
SUMX performs row-by-row calculations before summing up results:
👉 SUMX(Sales, Sales[Quantity] * Sales[Price])
Use SUMX when calculations involve multiple columns.
Comments
Post a Comment