← 30 Days Power BI Series
Day 10 of 30AdvancedDAX

Day 10: DAX — Advanced Patterns

5 questions · Power BI Interview Preparation

Q1

How do you calculate Moving Average in DAX?

3-Month Moving Average = CALCULATE( AVERAGE(Sales[Revenue]), DATESINPERIOD( 'Date Table'[Date], LASTDATE('Date Table'[Date]), -3, MONTH ) ) DATESINPERIOD returns a set of dates starting from LASTDATE (the last date in context) going back 3 months. CALCULATE then evaluates AVERAGE within that date range. Use in a line chart with Month on the axis to smooth out seasonal volatility.

💡 Interview tip: Moving averages smooth data for trend analysis. The key parameters: the date column, the anchor date (LASTDATE), the interval count, and the interval type (MONTH, QUARTER, DAY).
Q2

How do you implement Row-Level Security (RLS) in Power BI?

RLS restricts which rows of data a user sees based on their identity. Implementation: In Power BI Desktop, go to Modelling → Manage Roles → New Role → define a DAX filter expression on a table (e.g. [Region] = USERPRINCIPALNAME() or [RegionManager] = USERNAME()). Publish to Power BI Service → dataset settings → Security → add users to each role. When those users view the report, they only see rows matching their RLS filter. Test with "View as" in Desktop before publishing.

💡 Interview tip: RLS is a senior-level topic asked at companies with sensitive data (banking, HR, sales with territories). Know how to create roles in Desktop and assign users in Service.
Q3

What is ALLEXCEPT in DAX?

ALLEXCEPT(table, column1, column2, ...) removes all filters from a table EXCEPT the specified columns. Use when you want to remove most filters but keep one or two. Example: calculating revenue as % of region total (keeping Region filter but removing Product filter): Revenue % of Region = DIVIDE( SUM(Sales[Revenue]), CALCULATE(SUM(Sales[Revenue]), ALLEXCEPT(Sales, Sales[Region])) ) This keeps the Region filter intact while removing all other filters (Product, Month, etc.) for the denominator.

💡 Interview tip: ALLEXCEPT is useful when you need "grand total at a specific grouping level" — e.g. the regional total when calculating product-level percentages within regions.
Q4

What is a What-If Parameter in Power BI?

What-If Parameters create a user-controlled numeric slicer that feeds into DAX measures, enabling scenario analysis. In Power BI Desktop: Modelling → New Parameter → set Name, Data Type, Min, Max, Increment, Default. Power BI creates a disconnected table with the parameter values and a measure to retrieve the selected value. Use in a measure: Adjusted Revenue = SUM(Sales[Revenue]) * (1 + [Growth Rate Value]). A user moves the Growth Rate slicer from 0% to 20% and the report dynamically shows projected revenue — without touching the underlying data.

💡 Interview tip: What-If Parameters are impressive in dashboards and come up in finance/planning analyst interviews. The key insight: the parameter table is disconnected — it does not join to any other table.
Q5

What is the difference between EARLIER and VAR in DAX?

EARLIER(column) was the original way to reference the outer row context when inside a nested row context (e.g. in FILTER inside a calculated column). It is complex to understand and error-prone. VAR (variable) is the modern replacement — it captures a value before evaluation and uses it inside complex expressions, making DAX much more readable. Example with VAR: Rank = VAR CurrentRevenue = SUM(Sales[Revenue]) RETURN RANKX(ALL(Products), SUM(Sales[Revenue]), CurrentRevenue, DESC) Always use VAR/RETURN instead of EARLIER — it is clearer, easier to debug, and Microsoft recommends it.

💡 Interview tip: EARLIER is legacy DAX. If you see it in old code, understand it. For new code, always use VAR/RETURN. This shows modern DAX knowledge in interviews.
← Day 9All DaysDay 11

Want live Power BI coaching?

Join EVIKA Academy for hands-on Power BI training with real projects and placement support in Delhi NCR.

Book Free Demo →
Best Data Analytics Course in Noida Delhi NCR | EVIKA ACADEMY