Searchable quick reference

DAX & Power Query M Formula Reference

Recognize what each pattern does, what context it changes, and the exam clue that usually points to it.

DAX

SUM

Sum an existing numeric column.

DAX
Total Sales =
SUM ( Sales[SalesAmount] )
  • SUM aggregates a single existing numeric column.
  • Use an iterator such as SUMX when an expression must be evaluated row by row.
DAX

CALCULATE

Evaluate an expression after modifying filter context.

DAX
Blue Sales =
CALCULATE (
    [Total Sales],
    Product[Color] = "Blue"
)
  • The first argument is the expression/measure to evaluate.
  • Later arguments modify filter context.
  • CALCULATE also performs context transition when row context exists.
DAX

REMOVEFILTERS

Remove selected filters without clearing unrelated context.

DAX
Category % =
DIVIDE (
    [Total Sales],
    CALCULATE ( [Total Sales], REMOVEFILTERS ( Product[Category] ) )
)
  • The numerator stays in the current category.
  • Only Category is removed from the denominator.
  • Date, Region, Customer and other unrelated filters can remain.
DAX

KEEPFILTERS

Intersect a CALCULATE filter with an existing same-column filter.

DAX
Red Sales (keep) =
CALCULATE (
    [Total Sales],
    KEEPFILTERS ( Product[Color] = "Red" )
)
  • Without KEEPFILTERS, a same-column CALCULATE filter normally replaces the existing one.
  • KEEPFILTERS asks DAX to intersect instead.
DAX

ALLEXCEPT

Remove filters from a table except selected columns.

DAX
Sales by Year Only =
CALCULATE (
    [Total Sales],
    ALLEXCEPT ( 'Date', 'Date'[Year] )
)
  • Filters on other Date-table columns are removed.
  • The Year filter is retained.
  • Filters from unrelated tables are not automatically removed.
DAX

SUMX

Iterate a table and sum an expression.

DAX
Revenue =
SUMX (
    Sales,
    Sales[Quantity] * Sales[UnitPrice]
)
  • SUMX creates row context over Sales.
  • The expression is calculated for each row and then summed.
DAX

AVERAGEX + VALUES

Average aggregated results at a chosen entity grain.

DAX
Average Customer Sales =
AVERAGEX (
    VALUES ( Customer[CustomerID] ),
    [Total Sales]
)
  • VALUES returns distinct customers in current filter context.
  • AVERAGEX evaluates [Total Sales] for each customer and averages those totals.
DAX

FILTER

Return a filtered table expression.

DAX
High Value Sales =
CALCULATE (
    [Total Sales],
    FILTER ( Sales, Sales[SalesAmount] > 1000 )
)
  • FILTER evaluates its condition row by row and returns a table.
  • Use simple Boolean CALCULATE filters when they can express the requirement more directly.
DAX

DIVIDE

Perform safe division.

DAX
Margin % =
DIVIDE ( [Profit], [Revenue] )
  • DIVIDE safely handles zero/blank denominators.
  • An optional third argument can define the alternate result.
DAX

USERELATIONSHIP

Activate an existing inactive relationship for one calculation.

DAX
Shipped Sales =
CALCULATE (
    [Total Sales],
    USERELATIONSHIP ( 'Date'[Date], Sales[ShipDate] )
)
  • The inactive relationship is used for this calculation.
  • The model's active relationship is not permanently changed.
DAX

SAMEPERIODLASTYEAR

Shift the visible date set to the corresponding prior-year period.

DAX
Prior Year Sales =
CALCULATE (
    [Total Sales],
    SAMEPERIODLASTYEAR ( 'Date'[Date] )
)
  • Returns a prior-year date set.
  • Requires a sound date model for reliable time-intelligence behavior.
DAX

DATEADD

Shift the current date context by a chosen interval.

DAX
Previous Month Sales =
CALCULATE (
    [Total Sales],
    DATEADD ( 'Date'[Date], -1, MONTH )
)
  • -1 shifts backward one interval.
  • MONTH can be replaced with other supported intervals as needed.
DAX

TOTALYTD

Evaluate a measure over the year-to-date date set.

DAX
YTD Sales =
TOTALYTD ( [Total Sales], 'Date'[Date] )
  • Uses the Date column to build a year-to-date window.
  • Other dimension filters such as Product or Region remain unless removed.
DAX

SELECTEDMEASURE

Create reusable calculation-group transformations.

DAX
// Calculation item
CALCULATE (
    SELECTEDMEASURE(),
    DATESYTD ( 'Date'[Date] )
)
  • SELECTEDMEASURE refers to the measure currently being transformed by a calculation group.
  • DATESYTD applies the YTD date set.
DAX

DAX query: EVALUATE

Inspect model results with DAX Query View.

DAX
EVALUATE
SUMMARIZECOLUMNS (
    Product[Category],
    "Sales", [Total Sales]
)
  • EVALUATE returns a table expression in a DAX query.
  • SUMMARIZECOLUMNS groups results and can include measures.
DAX

USERPRINCIPALNAME

Build a common dynamic RLS rule.

DAX
UserAccess[UPN] = USERPRINCIPALNAME()
  • Returns the signed-in user's principal name in the Power BI Service.
  • Use a mapping/security table and relationships so the allowed rows propagate correctly.
Power Query M

Table.SelectRows

Filter rows.

Power Query M
Table.SelectRows(
    Source,
    each [Status] = "Active"
)
  • Source is the input table.
  • each evaluates the predicate for each row.
  • Supported source operations may fold back to the data source.
Power Query M

Table.SelectColumns

Keep only required columns.

Power Query M
Table.SelectColumns(
    Source,
    {"OrderDate", "ProductKey", "Amount"}
)
  • The second argument is a list of column names to retain.
  • Removing unused columns early can improve refresh and model efficiency.
Power Query M

Table.AddColumn

Add a calculated transformation column.

Power Query M
Table.AddColumn(
    Sales,
    "Revenue",
    each [Quantity] * [UnitPrice],
    type number
)
  • The new column is evaluated per row.
  • The final argument explicitly sets the result type.
Power Query M

Table.Group

Aggregate and change table grain.

Power Query M
Table.Group(
    Sales,
    {"Region"},
    {{"Sales", each List.Sum([Amount]), type number}}
)
  • Rows are grouped by Region.
  • The aggregation creates one result per group.
  • Grouping changes the table's stored grain.
Power Query M

Table.NestedJoin

Merge tables by key.

Power Query M
Table.NestedJoin(
    Sales, {"CustomerID"},
    Customer, {"CustomerID"},
    "Customer", JoinKind.LeftOuter
)
  • The key columns should have compatible data types.
  • LeftOuter retains all rows from the left table plus matches.
Power Query M

Table.Combine

Append compatible tables.

Power Query M
Table.Combine ( {January, February, March} )
  • Combines rows from the listed tables.
  • Append is a vertical operation; merge is a key-based horizontal operation.
Power Query M

Incremental refresh boundary

Filter using RangeStart and RangeEnd.

Power Query M
Table.SelectRows(
    Source,
    each [TransactionDate] >= RangeStart
        and [TransactionDate] < RangeEnd
)
  • RangeStart and RangeEnd are Date/Time parameters.
  • Using >= start and < end creates adjacent, non-overlapping boundaries.
  • Preserve query folding where supported.
Exam rule: don't memorize syntax without context. First identify the grain, current filters, required output and whether the transformation belongs in Power Query, the semantic model or a report visual.