DAX formula library
Copy-ready DAX patterns, each with an explanation, the model assumptions it needs and the mistakes to avoid.
Actual vs target variance and attainment
Show how far actual sales are above or below target, as a percentage of target.
Contribution % of total
Show each row as a percentage of the total of everything the user has selected.
Dynamic title from the selected years
Build a chart title that changes with the slicer, such as "Sales for 2023, 2024".
Selected value label with a fallback
Show the selected region (or any column value), or a friendly default when none or several are selected.
Keep slicer selections with KEEPFILTERS
Calculate a value for one category without overriding what the user selected in a slicer.
Remove a filter with REMOVEFILTERS
Calculate a value that ignores one table's filters, for example sales for all regions while one region is selected.
Fiscal year-to-date total
Accumulate sales from the start of the fiscal year, for fiscal years that do not begin in January.
Rank by sales
Give each product a rank (1 = best) that respects the slicers.
Top N products
Show sales only for the top N products and blank for the rest.
Rolling 3-month average
Average monthly sales over the current month and the two months before it.
Rolling 7-day average
Smooth daily numbers by averaging the last seven days.
Cumulative % of total (Pareto)
Rank items by sales and show the running share of the total, to see which items make up 80% of sales.
Running total over dates
A cumulative total that adds up everything from the first visible date to the current one.
Year-to-date total
Accumulate a measure from 1 January up to the date in the current context.
Month-over-month change %
Compare each month with the month before it.
Year-over-year change %
Compare this period with the same period last year and show the change as a percentage.