DAX Reference Guide
DAX Reference Guide
📊 Aggregation Functions
Aggregation functions summarise data across rows or tables. They are the backbone of most Power BI measures
and KPI cards.
SUM Aggregation
Syntax SUM(<column>)
Description Iterates row-by-row over a table and sums the result of an expression.
Essential for row-level calculations.
Example Profit After Discount = SUMX(Orders, Orders[Sales] * (1 -
Orders[Discount]) - Orders[Profit])
Output Calculates the net profit after applying per-row discounts — a row-context
aware sum.
Use Case Use when you need to compute something per row before aggregating, such
as revenue × margin for each order line.
AVERAGE Aggregation
Syntax AVERAGE(<column>)
Description Iterates a table, evaluates an expression per row, and returns the average.
Example Avg Profit Margin % = AVERAGEX(Orders, DIVIDE(Orders[Profit],
Orders[Sales]))
Output Returns average profit margin per order line — e.g. 12.47%
Use Case Computing per-product or per-region average margin rates without pre-
calculating a helper column.
COUNT Aggregation
Syntax COUNT(<column>)
Description Counts the number of rows containing non-blank numeric values in a column.
Example Count of Orders = COUNT(Orders[Sales])
Output Returns the number of order rows with a sales value — e.g. 9,994
Use Case Quick count of transactions; useful for order volume dashboards.
COUNTA Aggregation
Description Counts the number of non-blank values in a column (works on text and
numbers).
Example Unique Orders = COUNTA(Orders[Order ID])
Output Counts all order IDs including text-format IDs — e.g. 9,994
Use Case Counting rows in columns that contain text identifiers like Order ID or
Customer Name.
COUNTROWS Aggregation
Syntax COUNTROWS([<table>])
Output Returns count of orders from the West region — e.g. 3,203
Use Case Ideal for counting after applying filters; used extensively in measure
branching and KPIs.
DISTINCTCOUNT Aggregation
Syntax DISTINCTCOUNT(<column>)
Description Returns the smallest or largest value in a column (works on dates and
numbers).
Example First Order Date = MIN(Orders[Order Date]) | Last Order Date =
MAX(Orders[Order Date])
Description Evaluates an expression for the year-to-date period based on the current
filter context.
Example Sales YTD = TOTALYTD(SUM(Orders[Sales]), 'Date'[Date])
Output For a month slicer set to June 2017, returns cumulative sales from Jan–Jun
2017 — e.g. $336,492
Use Case Revenue YTD cards, KPI comparisons against annual targets, and running
total line charts.
Syntax SAMEPERIODLASTYEAR(<dates>)
Description Returns a table of dates corresponding to the same period in the previous
year. Typically wrapped in CALCULATE.
Example Sales LY = CALCULATE(SUM(Orders[Sales]),
SAMEPERIODLASTYEAR('Date'[Date]))
Output For a filter on Q2 2017, returns sum of Sales for Q2 2016 — e.g. $187,225
Use Case Year-over-year comparisons in line charts; showing last year's sales
alongside current year.
Description Shifts a set of dates backward or forward by a given interval (DAY, MONTH,
QUARTER, YEAR).
Example Sales Prev Month = CALCULATE(SUM(Orders[Sales]),
DATEADD('Date'[Date], -1, MONTH))
Output Returns sales for the prior month. If current month = Nov 2017, returns Oct
2017 sales — e.g. $128,307
Use Case Month-over-month comparisons, rolling window analysis, and lag/lead
metrics.
Description Returns a table of dates from the beginning of the year through the last date
Output Returns cumulative profit from Jan 1 through the selected date — e.g.
$47,138 through June 2017
Use Case Use inside CALCULATE for flexible YTD measures. Supports custom fiscal
year end (e.g. "3/31").
Syntax PREVIOUSMONTH(<dates>)
Description Returns all dates from the previous month based on the current context.
Example Qty Prev Month = CALCULATE(SUM(Orders[Quantity]),
PREVIOUSMONTH('Date'[Date]))
Output Returns total quantity sold in the prior month — e.g. 1,783 units in Oct 2017
Use Case Trend lines showing current vs previous month sales, used in executive
summary dashboards.
Syntax DATESMTD(<dates>)
Description Returns a set of dates from the beginning of the month up to the last date in
the current context.
Example MTD Sales = CALCULATE(SUM(Orders[Sales]),
DATESMTD('Date'[Date]))
Output Returns sales accumulated within the current month — e.g. $48,906 for Dec
1–15 2017
Use Case Month-to-date sales cards updated daily, used in operational reporting
dashboards.
Description Returns a table of dates for a rolling window period starting at a given date.
Example Rolling 90d Sales = CALCULATE(SUM(Orders[Sales]),
DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -90, DAY))
Output Returns total sales over the trailing 90 days from the latest selected date
Use Case Rolling average windows for trend smoothing, e.g. 30/60/90-day revenue or
profit analysis.
Output Returns sales scoped only to the West region regardless of any visual-level
slicer — e.g. $725,458
Use Case Used to override, expand, or restrict filter context for virtually every advanced
measure.
FILTER Filter
Output Counts all orders where Sales exceeds $1,000 — e.g. 1,244 orders
Use Case Used for conditional aggregations, segment analysis (e.g. only profitable
orders), and parameterised filtering.
Description Removes all filters from a table or specified columns; used to compute totals
ignoring slicer context.
Example Sales % of Total = DIVIDE(SUM(Orders[Sales]),
CALCULATE(SUM(Orders[Sales]), ALL(Orders)))
Output For Technology category: returns 36.4% — the share of total company sales
Use Case Percentage-of-total columns, market share calculations, and benchmark
measures.
Description Removes all filters from a table except those on the specified columns.
VALUES Filter
Syntax VALUES(<table_or_column>)
Description Returns a single-column table of distinct values in the current filter context.
Example Selected Category = IF(HASONEVALUE(Orders[Category]),
VALUES(Orders[Category]), "Multiple")
SELECTEDVALUE Filter
Description Returns the value of a column if filtered to one unique value; otherwise
returns the alternate.
Example Region Label = SELECTEDVALUE(Orders[Region], "All Regions")
Output Returns "East" when East is selected; "All Regions" when no or multiple
regions are selected
Use Case Dynamic title generation in report visuals; conditional logic based on slicer
state.
Syntax KEEPFILTERS(<expression>)
Output Returns Furniture sales only when the visual already shows Furniture;
otherwise blank.
Use Case Prevents a CALCULATE filter from overriding an existing slicer; useful in
cross-filter scenarios.
IF Logical
Output Adds a column with "Profitable" or "Loss" for every order row
Use Case Segmenting orders, products, or customers into performance tiers for colour-
coded visuals.
SWITCH Logical
Description Evaluates an expression against a list of values and returns the matching
result. Cleaner than nested IFs.
Example Region Label = SWITCH(Orders[Region], "West","🌵 West",
"East","🗽 East", "Central","🌽 Central", "South","🌴 South",
"Unknown")
Output Returns a labelled emoji string for each region — readable in slicers and
tooltips
Use Case Mapping codes or abbreviations to full names, scoring tiers, and readable
category labels.
AND / OR Logical
Description Logical AND/OR for use in DAX formulas (alternative: && and || operators).
Example Top Performer = IF(AND(Orders[Sales] > 500, Orders[Profit] >
100), "Yes", "No")
Output Flags rows where both Sales > $500 AND Profit > $100 as 'Yes'
Use Case Building multi-condition flags for conditional formatting, filtered measures,
and segment tagging.
IFERROR Logical
IN operator Logical
Description Tests whether a value belongs to a list of values. Returns TRUE or FALSE.
Example Is Key Segment = Orders[Segment] IN {"Corporate", "Home
Office"}
Output Returns TRUE for Corporate and Home Office rows, FALSE for Consumer
Use Case Filtering to relevant sub-groups without long OR chains; useful in calculated
columns and CALCULATE filters.
🔤 Text Functions
Text functions manipulate string values in calculated columns and can aid in data cleaning and label generation.
Description Joins two or more text strings into one. The & operator supports multiple
values directly.
Example Order Label = Orders[Order ID] & " - " & Orders[Customer Name]
Description Extracts a specified number of characters from the left, right, or middle of a
string.
Example Order Year Code = LEFT(Orders[Order ID], 2) -- returns "CA"
prefix Year Extract = MID(Orders[Order ID], 4, 4) -- returns
"2017"
Description Converts text to all uppercase, all lowercase, or title case (first letter of each
word capitalised).
Example Display Name = PROPER(Orders[Customer Name])
Output Converts "CLAIRE GUTE" → "Claire Gute" for clean visual display
Use Case Standardising inconsistently cased data imported from multiple source
systems.
LEN Text
Syntax LEN(<text>)
Description Returns the position of one string within another. SEARCH is case-
insensitive; FIND is case-sensitive.
Example Has Tech = IF(ISNUMBER(SEARCH("Tech", Orders[Category])),
"Yes", "No")
Output Returns "Yes" for rows where Category contains "Tech" (e.g. Technology)
Use Case Keyword detection in product names, flagging rows containing specific terms
for segment analysis.
Description Converts a value to text using a specified format. Useful for custom number
and date display.
Example Sales Display = FORMAT(SUM(Orders[Sales]), "$#,##0.00") Month
Name = FORMAT(Orders[Order Date], "MMM YYYY")
🔢 Mathematical Functions
Mathematical functions perform numeric transformations on column values or expressions.
DIVIDE Mathematical
Description Safe division that returns an alternate value (default: BLANK()) when
denominator is 0.
Example Profit Margin % = DIVIDE(SUM(Orders[Profit]),
SUM(Orders[Sales]), 0)
Output Returns 0.1247 (12.47%) and avoids divide-by-zero errors when Sales = 0
Use Case The preferred division function in DAX — always use DIVIDE instead of the /
operator.
ABS Mathematical
Syntax ABS(<number>)
Description INT rounds down to the nearest integer; TRUNC truncates decimal digits
without rounding.
Example Days to Ship = INT(Orders[Ship Date] - Orders[Order Date])
MOD Mathematical
Output Returns the leftover units when grouping by packs of 10 — e.g. 7 for Quantity
27
Use Case Determining remainder quantities for partial-case order analysis or batch
processing logic.
Description POWER raises a number to a given exponent; SQRT returns the square root.
Example CAGR = POWER(DIVIDE([Sales End], [Sales Start]), DIVIDE(1, 4))
- 1
Output Returns 0.0842 (8.42% compound annual growth rate over 4 years)
Use Case Financial growth rate calculations, index numbers, and statistical
transformations.
Description TODAY() returns the current date; NOW() returns the current date and time.
Example Days Since Last Order = TODAY() - MAX(Orders[Order Date])
Output Returns the number of days since the most recent order in the dataset
Use Case Creating real-time freshness indicators, days-open tickets, or elapsed-time
metrics.
Description Creates a date value from year, month, and day integers.
Example Q4 Start = DATE(2017, 10, 1)
Description Extracts the year, month number, or day number from a date column.
Example Order Year = YEAR(Orders[Order Date]) Order Month =
MONTH(Orders[Order Date])
Description WEEKDAY returns a number (1–7) for day of week; WEEKNUM returns the
week number in the year.
Example Is Weekend = IF(WEEKDAY(Orders[Order Date], 2) >= 6, "Weekend",
"Weekday")
Description Returns the number of intervals between two dates. Interval: SECOND,
Description Returns the last day of a month offset by the specified number of months.
Example Month End = EOMONTH(Orders[Order Date], 0)
ℹ️ Information Functions
Information functions interrogate the data type or blank status of values, enabling robust error-handling and data
quality checks.
ISBLANK Information
Syntax ISBLANK(<value>)
Output Labels rows without a discount value as 'No Discount'; others as 'Discounted'
Use Case Data quality audits, conditional logic when columns may have NULL values,
and filtering blank rows.
Output Returns the Sales value if it is numeric; otherwise returns 0 to prevent errors
Use Case Data validation in imported datasets where columns may have mixed types
due to ETL issues.
Syntax HASONEVALUE(<column>)
Description Returns TRUE when the column has exactly one distinct value in the current
filter context.
Example Dynamic Title = IF(HASONEVALUE(Orders[Category]), "Category: "
& SELECTEDVALUE(Orders[Category]), "All Categories")
CONTAINS Information
Description Returns TRUE if any row in the table has the specified column values.
Example Has West Orders = CONTAINS(Orders, Orders[Region], "West")
Output Returns TRUE if any order exists in the West region — used in conditional
card formatting
Use Case Checking data existence before computing a metric; used in dynamic
measure branching.
USERRELATIONSHIP Information
Description Activates an inactive relationship between two columns for the duration of a
CALCULATE expression.
Example Ship Date Sales = CALCULATE(SUM(Orders[Sales]),
USERELATIONSHIP(Orders[Ship Date], 'Date'[Date]))
Output Returns total sales evaluated by Ship Date rather than Order Date
Use Case Role-playing dimensions — using a single Date table for both Order Date and
Ship Date analyses.
🔗 Relationship Functions
Relationship functions navigate between related tables, allowing measures and calculated columns to access
fields from connected tables.
RELATED Relationship
Syntax RELATED(<column>)
Description Retrieves a related value from another table following the many-to-one
direction of a relationship.
Output Adds a Category column to the Orders table by looking up the related
Products table — e.g. "Furniture"
Use Case Denormalising related table attributes into fact tables for calculated column
creation.
RELATEDTABLE Relationship
Syntax RELATEDTABLE(<table>)
Description Returns a table filtered to rows related to the current row in a one-to-many
relationship.
Example Orders per Customer = COUNTROWS(RELATEDTABLE(Orders))
Output In the Customers table: returns the count of orders per customer — e.g. 6 for
Claire Gute
Use Case Computing customer-level metrics (total orders, average spend) from a
lookup/dimension table.
CROSSFILTER Relationship
Output Enables bidirectional filtering for this calculation — returns customer count
filtered by product attributes
Use Case Enabling cross-filter scenarios in star schemas without permanently setting
BOTH-direction relationships.
📈 Statistical Functions
Statistical functions provide descriptive statistics beyond simple aggregations — useful for financial analysis,
forecasting, and performance benchmarking.
Description Returns the population (P) or sample (S) standard deviation of a numeric
column.
Example Sales Std Dev = STDEV.S(Orders[Sales])
Output Returns ~$454.14 — indicating high variability in order size around the $229
average
Use Case Identifying volatility in sales, pricing consistency analysis, and outlier
Output Returns a large variance value indicating wide spread of profit across orders
Use Case Used in risk analysis dashboards to measure consistency of profitability
across product lines.
MEDIAN Statistical
Syntax MEDIAN(<column>)
Output Returns ~$54.49 — significantly lower than the mean, indicating right-skewed
distribution
Use Case Provides a more representative central tendency than AVERAGE when large
outliers are present.
[Link] Statistical
Description Returns the k-th percentile (inclusive) of a column, where k is between 0 and
1.
Example P90 Sales = [Link](Orders[Sales], 0.9)
RANKX Statistical
Description Returns the ranking of a value in a list for each row in a table.
Example Category Rank = RANKX(ALL(Orders[Category]),
SUM(Orders[Sales]))
GEOMEAN Statistical
Syntax GEOMEAN(<column>)
Description Returns the geometric mean — ideal for rates, ratios, and growth
percentages.
Example Avg Growth Rate = GEOMEAN(SalesGrowthTable[Growth Rate])
Output Returns compound average growth rate (CAGR) across multiple periods —
more accurate than arithmetic mean for rates
Use Case Analysing average discount rates, margin percentages, or YoY growth rates
accurately.