Skip to content

Table expressions and DAX queries

Measures return scalars; many DAX functions return rowsets. Know which shape the next function expects.

Function Result/use Pitfall
FILTER(table, condition) Eligible rows from a table expression Scanning a large fact table unnecessarily
SELECTCOLUMNS Selected/computed columns with explicit names Assuming it groups or removes duplicates
ADDCOLUMNS Existing rows plus computed columns Forgetting the row context of the added expression
SUMMARIZECOLUMNS Grouped results with expressions Assuming its blank-row behavior is the same as a SQL outer join
TOPN Top rows by an expression Assuming a guaranteed exact row count or output order
ROW One row of named scalar values Using a scalar directly after EVALUATE

Inspect a grouped query

EVALUATE
SUMMARIZECOLUMNS (
    DimRegion[Region],
    "Revenue", [Revenue],
    "Gross Profit", [Gross Profit]
)
ORDER BY DimRegion[Region]

The raw source expects saved measures or a preceding DEFINE block. The model-ready download includes the query-scoped measure definitions. Expected Revenue: North 4100, South 5400.

ORDER BY specifies the output order. A model's "Sort by column" setting does not automatically impose order on every DAX query.

Filter a table result deliberately

The time query builds a grouped result, then filters on its named Revenue Value column to remove periods with no current-month sales. This differs from blindly filtering the fact table before computing a cumulative measure.

For a saved Revenue measure, this illustrative query selects the top products:

EVALUATE
TOPN (
    3,
    SUMMARIZECOLUMNS ( DimProduct[ProductName], "Product Revenue", [Revenue] ),
    [Product Revenue], DESC
)
ORDER BY [Product Revenue] DESC

TOPN may return more than N rows when the Nth ordering value ties. The sample has distinct product totals, but a business report must decide its tie policy.

Keep grouping and grain explicit

More columns can change both the number of rows and the evaluation context. Adding Region to a ProductName query is not just a cosmetic formatting change. Predict the expected grouped row count and reconcile its totals.

Exercise: add Region to the product query and verify its Revenue totals still reconcile to 9500. Avoid broad bi-directional relationships to make unrelated dimensions appear connected.

Reference: DAX queries and SUMMARIZECOLUMNS.