Ravindra BagaleCourses & study guides मराठी Track your progress

30. Interview Questions and Answers

30.4 Power BI DAX Interview Questions and Answers

Q25. What is DAX?

Data Analysis Expressions – the formula language used in Power BI, Analysis Services and Power Pivot for calculated columns, measures, calculated tables and security rules.

Q26. Calculated column vs measure?

A calculated column is computed row by row at refresh and stored in the model; it can be used in slicers and axes. A measure is computed at query time based on the current filter context and not stored; used for aggregations and KPIs. Prefer measures for aggregations.

Q27. What are row context and filter context?

Row context is the current row during iteration (in calculated columns and X functions). Filter context is the set of filters (from visuals, slicers, filters and CALCULATE) that determines which rows are visible when a measure is evaluated.

Q28. What is context transition?

When CALCULATE is evaluated inside a row context, it converts the current row into an equivalent filter context. Measure references are implicitly wrapped in CALCULATE, so referencing a measure in a calculated column or iterator triggers context transition.

Q29. What does CALCULATE do?

It evaluates an expression in a modified filter context – adding, replacing or removing filters with its filter arguments and modifiers (ALL, REMOVEFILTERS, KEEPFILTERS, USERELATIONSHIP, CROSSFILTER). It is the most important DAX function.

Q30. SUM vs SUMX?

SUM aggregates a single column. SUMX iterates a table, evaluates an expression for each row (e.g. Orders[Quantity] * RELATED(Product[Unit Price])), then sums the results.

Worked example (fictional, hand-checked): Two lines: Qty 2 × ₹50 and Qty 1 × ₹300. SUMX(Lines, [Qty] * [Price]) = 100 + 300 = ₹400. SUM(Qty) * SUM(Price) = 3 × 350 = ₹1,050 (wrong).

Q31. COUNT vs COUNTROWS vs DISTINCTCOUNT?

COUNT counts non-blank values in a column; COUNTROWS counts the rows of a table (or table expression); DISTINCTCOUNT counts unique values in a column. Example: in an order-line table, COUNTROWS(Orders) gives order lines, while DISTINCTCOUNT(Orders[Order ID]) gives orders.

Worked example (fictional, hand-checked): On visuals_orders_apr_may_2026.csv: COUNTROWS(Orders) = 8; COUNT(Orders[Delivery Mins]) = 7 (cancelled 308 is blank); DISTINCTCOUNT(Orders[City]) = 3; DISTINCTCOUNT(Orders[Store]) = 5.

Q32. ALL vs ALLEXCEPT vs ALLSELECTED vs REMOVEFILTERS?

ALL removes filters from a table or columns (and can return a table). ALLEXCEPT removes all filters from a table except those on specified columns. ALLSELECTED removes filters coming from inside the visual but keeps outside filters like slicers – used for "% of visible total". REMOVEFILTERS works like ALL but only as a CALCULATE modifier and is more readable.

Worked example (fictional, hand-checked): On visuals_orders_apr_may_2026.csv, Pune = ₹850. Share with ALL(Orders[City]) as the denominator: 850 ÷ 2,100 = 40.5%. With a Platform slicer on Blinkit, Pune Blinkit = ₹650: ALLSELECTED(Orders[City]) gives 650 ÷ 1,100 = 59.1%, while ALL(Orders) gives 650 ÷ 2,100 = 31.0%.

Q33. FILTER vs CALCULATE filter arguments?

FILTER is an iterator that returns a table of rows meeting a condition – necessary for conditions on measures or complex logic. Simple column predicates in CALCULATE (e.g. Product[Category] = "Snacks") are more efficient. Filter columns, not whole tables.

RELATED returns a value from the one side of a relationship (used on the many side). RELATEDTABLE returns the related rows from the many side (used on the one side). LOOKUPVALUE finds a value based on search conditions without needing a relationship.

Q35. What is SELECTEDVALUE used for?

It returns the value of a column when exactly one value is in the filter context, otherwise an alternate result. Common for dynamic titles and parameter-driven logic, e.g. SELECTEDVALUE(DarkStore[City], "All Cities").

Q36. Why use DIVIDE instead of the / operator?

DIVIDE safely handles division by zero, returning BLANK or a specified alternate result instead of an error or infinity.

Worked example (fictional, hand-checked): Kolhapur has no delivered Blinkit orders: Sales ₹0 and Delivered Orders 0. DIVIDE(0, 0) returns blank; 0 / 0 returns NaN, which shows as an error-looking value in visuals.

Q37. How do you calculate YTD and previous-year sales?

TOTALYTD([Total Sales], 'Date'[Date]) or CALCULATE([Total Sales], DATESYTD('Date'[Date])) for YTD, and CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date])) for the same period last year. YoY % = DIVIDE(current − LY, LY).

Worked example (fictional, hand-checked): FY YTD with TOTALYTD([Total Sales], 'Date'[Date], "3/31") on the practice file: April ₹900, May ₹2,100. If (fictional) May 2025 sales were ₹1,000, YoY for May 2026 = (1,200 − 1,000) ÷ 1,000 = 20.0%.

Q38. DATEADD vs PARALLELPERIOD vs SAMEPERIODLASTYEAR?

SAMEPERIODLASTYEAR shifts the visible dates back one year. DATEADD shifts dates by any number of days, months, quarters or years. PARALLELPERIOD returns the full period(s) at the chosen level – e.g. the whole previous year even if only March is selected.

Q39. How do you create a running total?

CALCULATE([Total Sales], FILTER(ALL('Date'[Date]), 'Date'[Date] <= MAX('Date'[Date]))). For a total that restarts each year, use DATESYTD/TOTALYTD.

Worked example (fictional, hand-checked): On visuals_orders_apr_may_2026.csv, by date: 06-Apr ₹600 → 07-Apr ₹900 → 04-May ₹1,500 → 05-May ₹2,100.

Q40. How does RANKX work?

RANKX(table, expression, [value], [order], [ties]) evaluates the expression for each row of the table and returns the rank of the current value. Use ALL on the table so all items are compared, and choose SKIP or DENSE for ties.

Worked example (fictional, hand-checked): Stores by Total Sales: Kothrud 650 (1), College Road 500 (2), Rajarampuri 450 (3), Gangapur 300 (4), Baner 200 (5). By order count (2, 2, 2, 1, 1): SKIP gives 1, 1, 1, 4, 4; DENSE gives 1, 1, 1, 2, 2.

Q41. What are variables in DAX and their benefits?

Declared with VAR and returned with RETURN. They improve readability, allow easy debugging, and improve performance because each variable is evaluated only once. A variable's value is fixed where it is defined.

Q42. What is the difference between VALUES and DISTINCT?

Both return distinct values of a column. VALUES can include an extra blank row when there are fact rows with no matching dimension row (referential integrity violation); DISTINCT does not add this blank row.

Q43. How would you calculate Average Order Value (AOV) and Cancellation Rate?

AOV = DIVIDE([Total Sales], [Delivered Orders]). Cancellation Rate = DIVIDE([Cancelled Orders], [Total Orders]), where the order counts use DISTINCTCOUNT(Orders[Order ID]) with a CALCULATE filter on Order Status.

Worked example (fictional, hand-checked): On visuals_orders_apr_may_2026.csv: Total Sales ₹2,100 ÷ 7 delivered orders = AOV ₹300; 1 cancelled ÷ 8 orders = cancellation rate 12.5%.

Q44. Your fact table is at order-line level but delivery time is an order-level value. How do you average it correctly?

Take one value per order and then average across orders: AVERAGEX(VALUES(Orders[Order ID]), CALCULATE(MAX(Orders[Delivery Time Mins]))). A plain AVERAGE over the column would give orders with many lines more weight.

Worked example (fictional, hand-checked): Order A has 3 lines and took 10 min; order B has 1 line and took 20 min. Plain AVERAGE over lines = (10+10+10+20) ÷ 4 = 12.5 min (wrong). AVERAGEX over orders = (10 + 20) ÷ 2 = 15.0 min.

Q45. How do you compare two platforms (e.g. Blinkit vs Amazon Now) in one model?

Append both sources into one Orders table with a Platform column (same column names), then use Platform in slicers/legends – for example, comparing Blinkit and Amazon Now order counts in Pune or Nagpur – or measures such as CALCULATE([Total Orders], Orders[Platform] = "Blinkit").

Do not rush DAX answers – practise writing one line at a time while you explain it aloud.

Ravindra Bagale's Tip

Friends, many students write DAX from memory in interviews and forget brackets or commas under pressure. Practise writing the ten most common measures by hand (CALCULATE, ALL, SAMEPERIODLASTYEAR, RANKX, DIVIDE), and say what each line does as you write it. Remember this rule.

Loading DAX practice tasks...

  1. Total List Price (Easy): Measure: ListPrice Sum = SUM of ListPrice.
  2. Average days on market per country (Easy): Shown per Country. Measure: Avg DaysOnMarket = AVERAGE of DaysOnMarket.
  3. Price Realisation (Medium): Shown per Projects Name. Measure: Price Realisation = SUM of SoldPrice ÷ SUM of ListPrice.
  4. ListPrice for 2BHK only (Medium): Shown per City. Measure: ListPrice 2BHK = SUM of ListPrice where Type is "2BHK".
  5. Share of ListPrice (Medium): Shown per Projects Name. Measure: ListPrice Share = SUM of ListPrice ÷ SUM of ListPrice for all of Projects.
  6. How many projects per Type (Medium): Shown per Type. Measure: Projects Count = distinct count of ProjID in Units.
  7. ListPrice minus SoldPrice (Hard): Shown per Type. Measure: Gap = SUMX over Units of ListPrice − SoldPrice.
  8. Rank by ListPrice (Hard): Shown per Projects Name. Measure: ListPrice Rank = rank of [Total List Price] among all Projects Name values.
  9. ListPrice of the top 2 (Hard): Measure: Top 2 ListPrice = [Total List Price] for the 2 best Projects names.
  10. ListPrice in the first half-year (Medium): Shown per Country. Measure: H1 ListPrice = SUM of ListPrice for ListDate before 1 Oct 2025.

Ravi Sir's Cards for this lesson

मराठी cards