DAX Practice Challenges
Solve real analytical problems, get instant deterministic feedback, and earn XP.
Calculate Total Revenue
SUM AggregationCreate a measure that sums the total Revenue from the Sales table.
Total Units Sold
SUM AggregationCreate a measure named 'Total Quantity' to calculate the sum of Quantity sold in the Sales table.
Count Total Transactions
COUNTROWSCreate a measure 'Total Transactions' that counts the total number of rows in the Sales table using the recommended best practice function.
Unique Active Customers
DISTINCTCOUNTCreate a measure 'Active Customers' that calculates the count of unique CustomerIDs appearing in the Sales table.
Average Transaction Revenue
AVERAGECreate a measure 'Average Sale Value' that calculates the arithmetic mean of Revenue in the Sales table.
Total Cost of Goods
SUM AggregationCreate a measure 'Total Cost' calculating the sum of the Cost column from the Sales table.
Highest Priced Product
MAX FunctionCreate a measure 'Max Product Price' to find the highest unit price in the Products catalog.
Earliest Recorded Order Date
MIN on DatesCreate a measure 'First Sale Date' that determines the earliest Date in the Sales table.
Total Customer Count
COUNTROWS DimensionalCreate a measure 'Total Customers' counting the total number of registered customers in the Customers table.
Safe Average Order Value
DIVIDECalculate 'Average Order Value' by dividing [Total Revenue] by [Total Transactions] using the safe DIVIDE function with a 0 fallback.
Enterprise Segment Revenue
CALCULATE Filter ContextCreate a measure 'Enterprise Revenue' that calculates total revenue specifically where Customers[Segment] equals 'Enterprise'.
Global Grand Total (ALL)
ALL Filter ModifierCreate a measure 'All Sales Revenue' that computes total sales revenue across the entire dataset, ignoring any filters on the Sales table.
Revenue Share %
Percentage of TotalCalculate 'Revenue Contribution %' by dividing the filtered [Total Revenue] by the grand total revenue using ALL(Sales).
United States Revenue Only
Related Dimension FilterCreate a measure 'US Sales' that calculates total revenue where Customers[Country] = 'United States'.
High Value Transactions Filter
FILTER Table IteratorCreate a measure 'High Value Revenue' that sums Sales[Revenue] for transactions where Sales[Revenue] > 2000 using the FILTER function.
Software Category Sales
Product Dimension FilterCreate a measure 'Software Sales' that calculates total revenue where Products[Category] is 'Software'.
Removing Product Filters with REMOVEFILTERS
REMOVEFILTERSCreate a measure 'Sales All Products' calculating [Total Revenue] while clearing any filters on the Products table using REMOVEFILTERS.
Multiple Filter Conditions
Multiple Filters in CALCULATECreate a measure 'Corporate US Sales' for transactions where Customers[Country] = 'United States' AND Customers[Segment] = 'Corporate'.
Preserving Filters with KEEPFILTERS
KEEPFILTERSCreate a measure 'Kept Enterprise Sales' that uses KEEPFILTERS around Customers[Segment] = 'Enterprise' so existing slicers are intersected rather than replaced.
Clearing Single Column with ALL
Column-Level ALLCreate a measure 'Sales Across Segments' that removes filters exclusively from Customers[Segment] while preserving filters on Country and Product.
Calculate Total Margin with SUMX
SUMX Row ContextCreate a measure 'Total Margin' using SUMX to iterate through Sales and compute (Sales[Revenue] - Sales[Cost]) row-by-row.
Average Customer Revenue
AVERAGEX & Context TransitionCalculate 'Average Customer Revenue' by iterating through the Customers table and evaluating [Total Revenue] for each customer.
Count High Volume Transactions with COUNTX
COUNTXUse COUNTX over Sales to count rows where Quantity is at least 3.
Max Spend by Customer
MAXXCreate a measure 'Max Customer Spend' using MAXX across Customers evaluating [Total Revenue].
Extended Price Calculation with RELATED
SUMX with RELATEDCalculate 'Total Gross Revenue' by multiplying Sales[Quantity] by the product's catalog price Products[Price] using RELATED inside SUMX.
Minimum Non-Zero Margin
MINX with FilterFind the lowest positive transaction margin using MINX on Sales where Revenue > Cost.
Average Daily Revenue
AVERAGEX over DateCreate a measure 'Average Daily Sales' by averaging [Total Revenue] across all Date[Date] rows.
Concatenate Top Customer Names
CONCATENATEXCreate a measure 'Customer List' that joins customer names with a comma delimiter using CONCATENATEX.
Year-To-Date Revenue
TOTALYTDCreate a measure 'Revenue YTD' calculating the cumulative year-to-date total of [Total Revenue] using the Date[Date] calendar column.
Prior Year Revenue
SAMEPERIODLASTYEARCalculate 'Revenue Prior Year' using CALCULATE and SAMEPERIODLASTYEAR on the Date[Date] column.
Year-Over-Year Growth %
YoY Growth PatternCalculate 'YoY Growth %' using variables: Current Sales, Prior Year Sales, and safe division.
Previous Month Sales with DATEADD
DATEADD Month ShiftCreate 'Sales Previous Month' using DATEADD to shift the Date[Date] column back by 1 MONTH.
Quarter-To-Date Sales
TOTALQTDCreate a measure 'Revenue QTD' calculating cumulative sales for the current quarter using TOTALQTD.
Month-Over-Month Change
MoM Growth VarianceCreate a measure 'MoM Revenue Change' that computes the numerical difference between [Total Revenue] and the previous month's revenue.
Rolling 30-Day Revenue
DATESINPERIODCreate a measure 'Rolling 30 Days Revenue' using CALCULATE, [Total Revenue], and DATESINPERIOD starting from MAX(Date[Date]) for -30 days.
Full Year Rest of Prior Year with PARALLELPERIOD
PARALLELPERIODUse PARALLELPERIOD with -1 and YEAR to get the entire prior year's revenue regardless of which month is currently filtered.
Customer Segment Title with SELECTEDVALUE
SELECTEDVALUECreate a measure 'Report Header' displaying 'Sales for ' concatenated with the selected Customer segment, defaulting to 'All Customers'.
Customer Tiering with SWITCH(TRUE())
SWITCH TRUE PatternClassify performance based on [Total Revenue]: over 10000 -> 'Platinum', over 5000 -> 'Gold', otherwise -> 'Silver'.
Customer Rank by Revenue with RANKX
RANKXCreate a measure 'Customer Sales Rank' that ranks customers by [Total Revenue] across ALL(Customers).
Clean Variables Pattern
VAR RETURN DebuggingCalculate Profit Margin % using clean variables for Rev, Cost, Margin, and safe DIVIDE.
Dynamic Measure Selection
SWITCH with ParameterBuild a dynamic measure that returns [Total Revenue] if selected parameter is 'Revenue', [Total Quantity] if 'Quantity', else [Total Cost].
Safe Coalesce for Missing Data
COALESCEReturn the customer's phone or contact if present, falling back to 'No Contact Listed' using COALESCE.
Top 5 Customers Revenue with TOPN
TOPN Virtual TableCalculate the total revenue generated exclusively by the top 5 customers using CALCULATE and TOPN.
Distinct Active Products with VALUES
VALUES TableCount how many products have recorded sales in the current filter context using COUNTROWS(VALUES(Sales[ProductID])).
Virtual Table Aggregation with SUMMARIZE
SUMMARIZE & SUMXCalculate average revenue per country by iterating over a SUMMARIZE table of Countries using AVERAGEX.
Context Transition in Calculated Columns
Context TransitionExplain and demonstrate context transition: wrap SUM(Sales[Revenue]) inside CALCULATE so a row context becomes a filter context.
Dynamic Disconnected Slicer Treatment with TREATAS
TREATAS Virtual LineageApply a virtual relationship between an unlinked selection and Products[Category] using TREATAS.