SUM
Sum an existing numeric column.
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.
Recognize what each pattern does, what context it changes, and the exam clue that usually points to it.
Sum an existing numeric column.
Total Sales =
SUM ( Sales[SalesAmount] )
Evaluate an expression after modifying filter context.
Blue Sales =
CALCULATE (
[Total Sales],
Product[Color] = "Blue"
)
Remove selected filters without clearing unrelated context.
Category % =
DIVIDE (
[Total Sales],
CALCULATE ( [Total Sales], REMOVEFILTERS ( Product[Category] ) )
)
Intersect a CALCULATE filter with an existing same-column filter.
Red Sales (keep) =
CALCULATE (
[Total Sales],
KEEPFILTERS ( Product[Color] = "Red" )
)
Remove filters from a table except selected columns.
Sales by Year Only =
CALCULATE (
[Total Sales],
ALLEXCEPT ( 'Date', 'Date'[Year] )
)
Iterate a table and sum an expression.
Revenue =
SUMX (
Sales,
Sales[Quantity] * Sales[UnitPrice]
)
Average aggregated results at a chosen entity grain.
Average Customer Sales =
AVERAGEX (
VALUES ( Customer[CustomerID] ),
[Total Sales]
)
Return a filtered table expression.
High Value Sales =
CALCULATE (
[Total Sales],
FILTER ( Sales, Sales[SalesAmount] > 1000 )
)
Perform safe division.
Margin % =
DIVIDE ( [Profit], [Revenue] )
Activate an existing inactive relationship for one calculation.
Shipped Sales =
CALCULATE (
[Total Sales],
USERELATIONSHIP ( 'Date'[Date], Sales[ShipDate] )
)
Shift the visible date set to the corresponding prior-year period.
Prior Year Sales =
CALCULATE (
[Total Sales],
SAMEPERIODLASTYEAR ( 'Date'[Date] )
)
Shift the current date context by a chosen interval.
Previous Month Sales =
CALCULATE (
[Total Sales],
DATEADD ( 'Date'[Date], -1, MONTH )
)
Evaluate a measure over the year-to-date date set.
YTD Sales =
TOTALYTD ( [Total Sales], 'Date'[Date] )
Create reusable calculation-group transformations.
// Calculation item
CALCULATE (
SELECTEDMEASURE(),
DATESYTD ( 'Date'[Date] )
)
Inspect model results with DAX Query View.
EVALUATE
SUMMARIZECOLUMNS (
Product[Category],
"Sales", [Total Sales]
)
Build a common dynamic RLS rule.
UserAccess[UPN] = USERPRINCIPALNAME()
Filter rows.
Table.SelectRows(
Source,
each [Status] = "Active"
)
Keep only required columns.
Table.SelectColumns(
Source,
{"OrderDate", "ProductKey", "Amount"}
)
Add a calculated transformation column.
Table.AddColumn(
Sales,
"Revenue",
each [Quantity] * [UnitPrice],
type number
)
Aggregate and change table grain.
Table.Group(
Sales,
{"Region"},
{{"Sales", each List.Sum([Amount]), type number}}
)
Merge tables by key.
Table.NestedJoin(
Sales, {"CustomerID"},
Customer, {"CustomerID"},
"Customer", JoinKind.LeftOuter
)
Append compatible tables.
Table.Combine ( {January, February, March} )
Filter using RangeStart and RangeEnd.
Table.SelectRows(
Source,
each [TransactionDate] >= RangeStart
and [TransactionDate] < RangeEnd
)