Monday, November 30, 2026

Star Schema vs Flat Table in Power BI: VertiPaq Performance

Picture this. You import one wide "everything" table from a SQL view. It has orders, products, customers, dates, and freight, all in one place. The report works, until it doesn't. The file is bigger than you expected, refresh feels slow, and then someone notices that total freight is three times what finance reports. Every order line carried a copy of the order's freight, and your SUM added them all up.

Now you wonder whether the star schema everyone keeps recommending is worth the effort. This article answers that honestly. We will look at how the Power BI star schema and the flat table (also called one big table, or denormalization) behave inside VertiPaq, where each one helps, and where each one hurts. I will not give you a magic speed multiplier, because it would be made up. Results depend on your data, your column cardinality, and your queries. What you will get is a way to reason about the trade-off and a way to measure it yourself.

The Sample Data Model Used in This Article

Every example uses the same model, so you can compare designs without re-learning the tables.

  • Customer (dimension): CustomerKey, CustomerID, CustomerName, Gender, BirthDate, Segment, City, State, Country, Region, JoinDate.
  • Product (dimension): ProductKey, ProductID, ProductName, Category, Subcategory, Brand, Color, Size, UnitCost, ListPrice, LaunchDate.
  • Date (dimension): one row per day, no gaps, marked as the date table on [Date].
  • Sales (fact, order header): one row per order, with CustomerKey, OrderDate (active), ShipDate (inactive), SalesChannel, PaymentMethod, Freight, TaxAmount.
  • Sales Order Details (fact, order lines): one row per product per order, with SalesOrderID, ProductKey, Quantity, UnitPrice, DiscountPct, SalesAmount, TotalCost.

All relationships are one-to-many and single direction: Customer to Sales, Date to Sales on OrderDate (active), Date to Sales on ShipDate (inactive), Sales to Sales Order Details, and Product to Sales Order Details. Customer and Date filters flow through Sales into Sales Order Details. Product filters reach only Sales Order Details. Header-level amounts (Freight, TaxAmount) are not filtered by Product, and we will keep coming back to that.

These are the base measures, defined once and reused throughout:

Total Sales = SUM ( 'Sales Order Details'[SalesAmount] )

Total Cost = SUM ( 'Sales Order Details'[TotalCost] )

Total Profit = [Total Sales] - [Total Cost]

Profit Margin % = DIVIDE ( [Total Profit], [Total Sales] )

Total Quantity = SUM ( 'Sales Order Details'[Quantity] )

Order Count = DISTINCTCOUNT ( Sales[SalesOrderID] )

Total Freight = SUM ( Sales[Freight] )

Sales by Ship Date =
CALCULATE (
    [Total Sales],
    USERELATIONSHIP ( 'Date'[Date], Sales[ShipDate] )
)

Average Order Value = DIVIDE ( [Total Sales], [Order Count] )

Sales All Products = CALCULATE ( [Total Sales], REMOVEFILTERS ( Product ) )

% of All Products = DIVIDE ( [Total Sales], [Sales All Products] )

Sales Previous Year = CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )

Sales YTD = CALCULATE ( [Total Sales], DATESYTD ( 'Date'[Date] ) )

Sales Fiscal YTD = CALCULATE ( [Total Sales], DATESYTD ( 'Date'[Date], "6-30" ) )

Core Concepts, Explained Simply

Star Schema vs Flat Table

A star schema puts measurable events (facts) in the middle and descriptions (dimensions) around them, joined by one-to-many relationships. Think of a library catalogue. A book card points to an author card, and the author's biography is written once. In our model, Sales and Sales Order Details are the facts, and Customer, Product, and Date are the dimensions.

A flat table (one big table) joins everything upfront into a single wide table. It is like a spreadsheet where every row restates the author's biography. It is simple to look at, but the same descriptive text appears on every row.

What VertiPaq Is

VertiPaq is the in-memory, column-oriented storage engine behind Power BI (Import mode) and SSAS Tabular. "Column-oriented" means each column is stored and compressed separately, like a filing cabinet with one drawer per column. That suits analytics, where a query usually touches a few columns, not entire rows.

Two compression ideas matter here, and I will stay at the level I am sure about. Dictionary encoding stores each distinct value of a column once in a dictionary, and the rows hold compact references to it. It works like a phone contact list: you save a name once and refer to it by entry. Run-length encoding stores a repeated value as "this value, this many times in a row", which helps when consecutive rows repeat. Data is also split into segments. I will not quote segment sizes or thresholds, so check the current documentation for those.

Column Cardinality

Cardinality is the number of distinct values in a column. It is the main driver of column size. A column such as Segment has three values, so its dictionary is tiny. A column such as an order ID, a timestamp, or free text has many distinct values, so its dictionary is large and it compresses poorly. That is why high-cardinality columns are expensive, and why unused ones are the first thing to remove.

Storage Engine vs Formula Engine

In simple terms, the storage engine scans and aggregates the compressed data, and it can work in parallel. The formula engine evaluates the DAX logic, such as iterators and complex expressions, and generally works single-threaded. Model shape affects both. It changes what the storage engine must scan, and it changes how much logic the formula engine must write to get the right answer.

Grain

Grain is the level of detail of a table. Sales has one row per order. Sales Order Details has one row per product per order. When you join them into one flat table, the grain becomes one row per order line, and every order-level value (Freight, TaxAmount) is repeated on each line. That repetition is the root of the inflated-freight story from the introduction.

How Each Design Behaves in VertiPaq

Where Repeated Text Lives

In a star schema, CustomerName, Segment, ProductName, and Category sit once per dimension row. In a flat table, those columns exist on every line row. Dictionary encoding still stores each distinct value once, so a low-cardinality column like Category may compress well even when repeated. A high-cardinality column like CustomerName repeated across a huge number of lines can still be costly. The outcome depends on your data.

Relationship Cost vs Wide-Table Scan

A star schema adds relationships, and filtering through them has a cost. A flat table avoids relationships but has more, wider columns on the large table. Neither is always smaller or faster. It depends on the data, the cardinality of the columns, and the queries you run. Measure your own model instead of trusting a rule.

Filter Propagation

In a star schema, a dimension filter travels through a relationship to the fact table. In a flat table, every filter is a plain column filter on the same table. The flat version is conceptually simpler. The star version lets one dimension filter several fact tables.

Date Handling

A dedicated, marked 'Date' table has unique, contiguous dates. It is the supported foundation for time intelligence functions such as SAMEPERIODLASTYEAR and DATESYTD. It also supports the role-playing pattern, where OrderDate is active and ShipDate is activated with USERELATIONSHIP. A fact column of raw dates has repeated dates and only the days that had sales, so it lacks those guarantees. I would not rely on time intelligence over such a column without testing it. Examples 11 to 14 explore this.

Header-Level Amounts

In a flat table, Freight and TaxAmount repeat on every line of an order, so SUM overcounts. In the star schema they stay on Sales, one row per order, so the sum is correct.

Maintainability and Reuse

Conformed dimensions give you one place to fix a product name and consistent slicers across several fact tables. In a flat table, the fix must flow through every row, and each additional fact table would need its own copy of the descriptive columns.

Auto Date/Time

When the auto date/time option is enabled, Power BI creates hidden date tables for date columns. Their exact behavior and defaults have changed over time, so check the current documentation and your own settings. With a proper Date table, many authors turn this option off.

How to Measure It

  • VertiPaq Analyzer (available through DAX Studio and Tabular Editor) reports storage statistics for your model. Typically that means sizes per table, column, dictionary, and relationship, plus column cardinality. You can usually save the results to compare before and after a change.
  • DAX Studio Server Timings separates a query's time into storage engine and formula engine work, and shows the storage engine queries that were sent.
  • Power BI Performance Analyzer records how long each visual takes to refresh, and lets you copy the DAX query behind a visual.
  • The DAX query view in Power BI Desktop lets you run EVALUATE queries, which is ideal for validating totals between designs.

A simple method: build both designs from the same source, compare total model size and the size of the biggest columns, run the same visuals' queries on both, and compare timings (clear the cache between runs so they are comparable). Finally, reconcile the totals.

Star Schema vs Flat Table: Comparison

AspectStar schemaFlat table
Model structureTwo fact tables with Customer, Product, and Date dimensionsOne table at order-line grain
Data duplicationDescriptive attributes stored once per dimension rowAttributes repeated on every line row
Expected storage behaviorSmaller descriptive columns, plus relationship structures; depends on the dataWider large table; low-cardinality text may compress well; depends on the data
RelationshipsFive one-to-many relationshipsNone needed within the table itself
GrainEach table has one clear grainOne grain; header-level values repeat on each line
Time intelligenceMarked Date table; role-playing dates with USERELATIONSHIPRaw date columns; test carefully, or add a Date table
Header-level amountsFreight and TaxAmount live on Sales; sums are correctRepeated per line; a plain SUM overcounts
MaintainabilityFix an attribute once in its dimensionFix flows through the wide table; no sharing across facts
Refresh and ETL effortSeveral tables with clean keysJoin work moves upstream into one query
Report author experienceFields grouped by tableOne long field list
Typical fitShared, growing, multi-fact modelsSmall, single-grain, quick analysis
Main limitationNeeds design effort and clean keysMixed grain and no reuse

Pros, Cons, and Limitations

Star Schema

  • Pros: descriptions stored once, correct header-level amounts, reusable dimensions, a proper Date table, clear grain per table.
  • Cons: more design and key-cleaning work, more tables for authors to learn.
  • Limitations: filters do not cross every relationship, so header-level measures by Product can mislead. Performance depends on the model and the query.

Flat Table

  • Pros: simple to build, no relationships to manage, easy for small one-off work.
  • Cons: mixed grain, repeated attributes, header amounts overcount, harder to reuse across facts.
  • Limitations: time intelligence needs care, and size or speed benefits are not guaranteed. They depend on the model and the query.

Which One Should You Use?

  1. A flat table is acceptable when the data is small, there is one fact grain, the model is a one-off, and no one needs header-level amounts or shared dimensions.
  2. Use a star schema when you have more than one fact table, header-level amounts, a need for time intelligence, or a model that others will extend.
  3. Consider a hybrid when a few descriptive columns are denormalized on purpose, or you need a snowflake (a dimension linked to another dimension) or a narrow aggregation table. Test any hybrid against your own model.

Rule of thumb: one grain per table, facts in the middle, descriptions around them.

20 Examples on the Sample Data Model

The Hypothetical 'Sales Flat' Table

The Sample Data Model has no flat table, so I am adding one hypothetical table, 'Sales Flat'. It has one row per order line, with the columns of Sales Order Details (SalesOrderLineID, SalesOrderID, ProductKey, Quantity, UnitPrice, DiscountPct, SalesAmount, TotalCost) plus these denormalized columns: OrderDate, ShipDate, CustomerName, Segment, Country, ProductName, Category, Subcategory, SalesChannel, Freight, TaxAmount. It has no relationships to other tables. Flat-table measures are declared in the example where they first appear, and I assume they exist in the model afterward.

Beginner

Example 01: The Same Question in Both Designs

Type: two DAX queries (EVALUATE). No new measures.

EVALUATE
DISTINCT ( Product[Category] )
ORDER BY Product[Category]

EVALUATE
DISTINCT ( 'Sales Flat'[Category] )
ORDER BY 'Sales Flat'[Category]

Run each query separately in the DAX query view or DAX Studio. Both list the product categories, so both designs can answer the same question. The star query reads the small Product dimension. The flat query reads a column of the large table. The lesson: the Product dimension may list categories that have never sold, while 'Sales Flat' can only list categories that appear on a line. Compare the two results.

Example 02: Total Sales by Category (Star Schema)

Type: DAX query. Uses [Total Sales].

EVALUATE
SUMMARIZECOLUMNS (
    Product[Category],
    "Total Sales", [Total Sales]
)
ORDER BY Product[Category]

Product[Category] filters Sales Order Details through the Product relationship, and SUM adds SalesAmount for each category. SUMMARIZECOLUMNS groups by the column and evaluates the measure for each group. It also drops rows where every measure is blank. Keep this result as the reference for the next two examples.

Example 03: The Same Result on 'Sales Flat'

Type: new measure, then a DAX query. New measure: [Flat Total Sales].

Flat Total Sales = SUM ( 'Sales Flat'[SalesAmount] )

EVALUATE
ADDCOLUMNS (
    VALUES ( Product[Category] ),
    "Star Total Sales", [Total Sales],
    "Flat Total Sales",
        VAR CurrentCategory = Product[Category]
        RETURN
            CALCULATE (
                [Flat Total Sales],
                'Sales Flat'[Category] = CurrentCategory
            )
)
ORDER BY Product[Category]

Because 'Sales Flat' has no relationship to Product, a Product filter cannot reach it. The query therefore captures the category in a variable and applies it as a column filter on the flat table. That is a neat demonstration of the filter-propagation difference. The two columns should match if the flat table was built correctly. If a category appears with a blank flat value, check for unmatched or differently spelled categories.

Example 04: Reconciling at the Grand Total

Type: DAX query. Uses [Total Sales] and [Flat Total Sales].

EVALUATE
ROW (
    "Total Sales", [Total Sales],
    "Flat Total Sales", [Flat Total Sales],
    "Difference", [Total Sales] - [Flat Total Sales]
)

If the flat table was built correctly, the difference is zero. A non-zero difference points to dropped rows, for example from an inner join, or to duplicated rows from a join that multiplied lines. Reconcile the totals before comparing any performance numbers. A faster model that gives wrong totals is not an improvement.

Example 05: Column Cardinality

Type: DAX query. No new measures.

EVALUATE
ROW (
    "Customer Rows", COUNTROWS ( Customer ),
    "Distinct CustomerName", DISTINCTCOUNT ( Customer[CustomerName] ),
    "Distinct Country", DISTINCTCOUNT ( Customer[Country] ),
    "Distinct Segment", COUNTROWS ( VALUES ( Customer[Segment] ) ),
    "Product Rows", COUNTROWS ( Product ),
    "Distinct ProductName", DISTINCTCOUNT ( Product[ProductName] ),
    "Distinct Category", COUNTROWS ( VALUES ( Product[Category] ) )
)

This shows how many distinct values each column holds. Segment and Category should be tiny, while names should be close to the row count. Low-cardinality columns tend to have small dictionaries, and high-cardinality ones tend to be expensive. Both counting approaches include the blank value if one exists. Use the result to decide which columns deserve attention.

Intermediate: Filter Context and Grain

Example 06: Freight by Country (Star Schema)

Type: DAX query. Uses [Total Freight].

EVALUATE
SUMMARIZECOLUMNS (
    Customer[Country],
    "Total Freight", [Total Freight]
)
ORDER BY Customer[Country]

Freight sits on Sales, with one row per order. Customer filters Sales directly, so each order's freight is counted exactly once. This is correct because the filter and the amount share the same grain. Slicing header-level amounts by Customer or Date is safe in this model.

Example 07: Freight Overcounts on 'Sales Flat'

Type: new measure, then a DAX query. New measure: [Flat Total Freight].

Flat Total Freight = SUM ( 'Sales Flat'[Freight] )

EVALUATE
TOPN (
    10,
    FILTER (
        ADDCOLUMNS (
            VALUES ( 'Sales Flat'[SalesOrderID] ),
            "Line Count", CALCULATE ( COUNTROWS ( 'Sales Flat' ) ),
            "Flat Freight", [Flat Total Freight],
            "Header Freight",
                VAR CurrentOrder = 'Sales Flat'[SalesOrderID]
                RETURN
                    CALCULATE ( [Total Freight], Sales[SalesOrderID] = CurrentOrder )
        ),
        [Line Count] > 1
    ),
    [Flat Freight], DESC
)

For each multi-line order, the flat freight is the order's freight multiplied by its line count, while the header freight is correct. The table's grain is the order line, but Freight belongs to the order. Summing a column at the wrong grain duplicates the value. On a large model this query is heavy because it iterates every order, so test it on a small dataset.

Example 08: A Corrected Flat-Table Measure

Type: new measure. New measure: [Flat Total Freight Corrected]. It needs no new column.

Flat Total Freight Corrected =
SUMX (
    VALUES ( 'Sales Flat'[SalesOrderID] ),
    CALCULATE ( MAX ( 'Sales Flat'[Freight] ) )
)

The measure iterates each distinct order, takes the freight for that order, and adds it once. It relies on Freight being identical on every line of an order, which you should verify. It also iterates a high-cardinality column, so it may be slower on large data, and you should measure it. The better fix is to keep Freight on a header-grain table, as the star schema does.

Example 09: Freight by Category Is Misleading

Type: DAX query. Uses [Total Freight] and [Total Sales].

EVALUATE
SUMMARIZECOLUMNS (
    Product[Category],
    "Total Sales", [Total Sales],
    "Total Freight", [Total Freight]
)
ORDER BY Product[Category]

Product filters flow only to Sales Order Details, and Freight lives on Sales, so the filter never reaches it. Expect every category to show the same overall freight, so adding up the column would multiply the real total. The model gives no error, which makes this easy to miss. Do not slice header-level amounts by Product columns, and treat any such visual as wrong unless you have allocated the amount deliberately.

Example 10: Order Count vs Distinct Orders on 'Sales Flat'

Type: new measures, then a DAX query. New measures: [Flat Order Count], [Orders With Lines].

Flat Order Count = DISTINCTCOUNT ( 'Sales Flat'[SalesOrderID] )

Orders With Lines = DISTINCTCOUNT ( 'Sales Order Details'[SalesOrderID] )

EVALUATE
SUMMARIZECOLUMNS (
    Product[Category],
    "Order Count", [Order Count],
    "Orders With Lines", [Orders With Lines],
    "Flat Order Count", [Flat Order Count]
)
ORDER BY Product[Category]

[Order Count] counts orders in Sales, which Product does not filter, so it repeats the same number for each category. [Orders With Lines] counts orders from the line table, and [Flat Order Count] counts orders found in the flat table. Those two should agree by category. At the grand total, [Order Count] can differ if some orders have no lines. The lesson: the same word, "orders", can mean different things depending on which table you count.

Intermediate: Time Intelligence and Relationships

Example 11: YTD and Previous Year (Star Schema)

Type: DAX query. Uses [Total Sales], [Sales YTD], [Sales Previous Year].

EVALUATE
SUMMARIZECOLUMNS (
    'Date'[MonthYearSort],
    'Date'[MonthYear],
    "Total Sales", [Total Sales],
    "Sales YTD", [Sales YTD],
    "Sales Previous Year", [Sales Previous Year]
)
ORDER BY 'Date'[MonthYearSort]

The marked Date table has every day, so DATESYTD and SAMEPERIODLASTYEAR can shift whole periods reliably. Grouping by MonthYearSort first keeps months in chronological order. Months with no sales still exist in the Date table, though SUMMARIZECOLUMNS will hide rows where all three measures are blank. The result depends on your data's date range.

Example 12: The Same Pattern on 'Sales Flat'

Type: measure to test. New measure: [Flat Sales Previous Year Test].

Flat Sales Previous Year Test =
CALCULATE (
    [Flat Total Sales],
    SAMEPERIODLASTYEAR ( 'Sales Flat'[OrderDate] )
)

This is an experiment, not a recommendation. 'Sales Flat'[OrderDate] repeats dates and contains only the days with sales, so it lacks the unique, gap-free dates a marked Date table guarantees. I will not promise how it behaves. Put it in a visual by month and by day, compare it with example 11, and look for gaps. The dependable fix is to relate a proper Date table to the flat table, which makes it a hybrid design.

Example 13: Sales by Ship Date

Type: DAX query. Uses [Total Sales] and [Sales by Ship Date].

EVALUATE
SUMMARIZECOLUMNS (
    'Date'[MonthYearSort],
    'Date'[MonthYear],
    "Sales by Order Date", [Total Sales],
    "Sales by Ship Date", [Sales by Ship Date]
)
ORDER BY 'Date'[MonthYearSort]

Date has an active relationship to Sales[OrderDate] and an inactive one to Sales[ShipDate]. USERELATIONSHIP switches to the inactive one just for that measure. The same Date table therefore plays two roles, order date and ship date. 'Sales Flat' has both date columns, but without a Date table you can only group by the raw columns. To get the same behavior you would relate a Date table to it twice, which again means moving toward a star.

Example 14: Fiscal YTD with "6-30"

Type: DAX query. Uses [Total Sales] and [Sales Fiscal YTD].

EVALUATE
SUMMARIZECOLUMNS (
    'Date'[FiscalYear],
    'Date'[MonthYearSort],
    'Date'[MonthYear],
    "Total Sales", [Total Sales],
    "Sales Fiscal YTD", [Sales Fiscal YTD]
)
ORDER BY 'Date'[MonthYearSort]

The second argument of DATESYTD is the year-end date, given as a text literal. "6-30" means the year ends on June 30, so the fiscal year starts on July 1. The year part is not needed, and the exact text format can depend on locale, so check the current documentation. Confirm that your Date[FiscalYear] column uses the same June year-end, or the two will disagree. The running total restarts on July 1 each year.

Advanced and Pitfalls in Practice

Example 15: Percent of All Products

Type: DAX queries and two new measures. New measures: [Flat Sales All Products], [Flat % of All Products].

EVALUATE
SUMMARIZECOLUMNS (
    Product[Category],
    "Total Sales", [Total Sales],
    "% of All Products", [% of All Products]
)
ORDER BY Product[Category]

Flat Sales All Products =
CALCULATE (
    [Flat Total Sales],
    REMOVEFILTERS (
        'Sales Flat'[Category],
        'Sales Flat'[Subcategory],
        'Sales Flat'[ProductName]
    )
)

Flat % of All Products = DIVIDE ( [Flat Total Sales], [Flat Sales All Products] )

EVALUATE
SUMMARIZECOLUMNS (
    'Sales Flat'[Category],
    "Flat Total Sales", [Flat Total Sales],
    "Flat % of All Products", [Flat % of All Products]
)
ORDER BY 'Sales Flat'[Category]

In the star schema, REMOVEFILTERS ( Product ) clears every product attribute in one go. In the flat table you must list each product column, and forgetting one leaves a filter behind. Removing filters from the whole 'Sales Flat' table would also clear customer and date filters, which is rarely what you want. Both versions should return the same percentages if the flat table is correct.

Example 16: Fact Rows with No Matching Dimension Row

Type: DAX query. No new measures.

EVALUATE
ROW (
    "Lines With Unmatched Product",
        COUNTROWS (
            FILTER ( 'Sales Order Details', ISBLANK ( RELATED ( Product[ProductKey] ) ) )
        ) + 0,
    "Sales On Unmatched Product",
        SUMX (
            FILTER ( 'Sales Order Details', ISBLANK ( RELATED ( Product[ProductKey] ) ) ),
            'Sales Order Details'[SalesAmount]
        ),
    "Orders With Unmatched Customer",
        COUNTROWS (
            FILTER ( Sales, ISBLANK ( RELATED ( Customer[CustomerKey] ) ) )
        ) + 0
)

RELATED returns blank when a fact row has no matching dimension row. When this happens, the model groups those rows under an extra blank row, the unknown member, in the dimension, and you see it as (Blank) in visuals. Adding zero turns an empty count into 0 instead of blank. A flat table hides this problem because the join already dropped or blanked those rows upstream. How many rows you find depends entirely on your data.

Example 17: A Small Denormalized Calculated Table

Type: calculated table. New table: 'Sales Extract Demo'.

Sales Extract Demo =
SELECTCOLUMNS (
    'Sales Order Details',
    "SalesOrderLineID", 'Sales Order Details'[SalesOrderLineID],
    "SalesOrderID", 'Sales Order Details'[SalesOrderID],
    "Category", RELATED ( Product[Category] ),
    "Segment", RELATED ( Customer[Segment] ),
    "SalesAmount", 'Sales Order Details'[SalesAmount]
)

The table follows the line-to-product and line-to-order-to-customer relationships to pull in two descriptive columns. It produces a small flat extract inside the model. A calculated table is stored in the model, so it adds to model size, and it is recalculated when the model refreshes. SalesOrderLineID is a high-cardinality column, so include it only if you need it. Treat the table as a demo or a targeted aggregation source, not a replacement for good modeling.

Example 18: Flattening with a SQL Join

Type: SQL fragment (illustrative source table names, adjust to your database).

SELECT
    d.SalesOrderLineID, d.SalesOrderID, d.ProductKey,
    d.Quantity, d.UnitPrice, d.DiscountPct, d.SalesAmount, d.TotalCost,
    s.OrderDate, s.ShipDate, s.SalesChannel, s.Freight, s.TaxAmount,
    c.CustomerName, c.Segment, c.Country,
    p.ProductName, p.Category, p.Subcategory
FROM SalesOrderDetails AS d
LEFT JOIN Sales    AS s ON s.SalesOrderID = d.SalesOrderID
LEFT JOIN Customer AS c ON c.CustomerKey  = s.CustomerKey
LEFT JOIN Product  AS p ON p.ProductKey   = d.ProductKey;

This joins the line table to the order header, customer, and product, and returns one row per order line, the 'Sales Flat' grain. Order-level columns (Freight, TaxAmount, dates) are repeated on every line of the order. I used left joins from the lines so that unmatched keys remain visible instead of silently disappearing, which an inner join would do. Reconcile the row count and sales total against the source after building it.

Example 19: Average Order Value and Profit Margin on Both Designs

Type: new measures, then a DAX query. New measures: [Flat Total Cost], [Flat Total Profit], [Flat Profit Margin %], [Flat Average Order Value].

Flat Total Cost = SUM ( 'Sales Flat'[TotalCost] )

Flat Total Profit = [Flat Total Sales] - [Flat Total Cost]

Flat Profit Margin % = DIVIDE ( [Flat Total Profit], [Flat Total Sales] )

Flat Average Order Value = DIVIDE ( [Flat Total Sales], [Flat Order Count] )

EVALUATE
ROW (
    "Average Order Value", [Average Order Value],
    "Flat Average Order Value", [Flat Average Order Value],
    "Profit Margin %", [Profit Margin %],
    "Flat Profit Margin %", [Flat Profit Margin %]
)

Both pairs should reconcile when the flat table is built correctly and no orders are missing lines. The flat average order value divides by distinct orders, not by rows, which is the key choice. Dividing by COUNTROWS ( 'Sales Flat' ) would give an average line value instead. The pitfall appears when someone adds a header-level column such as Freight to a flat-table sum, since it is repeated on every line.

Example 20: One Validation Query for Both Designs

Type: DAX query with a query-scoped measure. New measure: [Flat Total Quantity] (defined inside the query).

DEFINE
    MEASURE 'Sales Flat'[Flat Total Quantity] = SUM ( 'Sales Flat'[Quantity] )

EVALUATE
UNION (
    ROW (
        "Design", "Star schema",
        "Sales", [Total Sales],
        "Cost", [Total Cost],
        "Quantity", [Total Quantity],
        "Orders", [Order Count]
    ),
    ROW (
        "Design", "Flat table",
        "Sales", [Flat Total Sales],
        "Cost", [Flat Total Cost],
        "Quantity", [Flat Total Quantity],
        "Orders", [Flat Order Count]
    )
)

The query returns one row per design with the same four totals, so you can compare them at a glance. Defining the quantity measure inside the query avoids changing the model just to validate it. Differences in Sales, Cost, or Quantity point to dropped or duplicated lines. A difference only in Orders may mean orders without lines. Run this after every rebuild of either design.

Common Pitfalls

  • Summing header-level amounts on line rows. Freight and TaxAmount repeat on each line, so the total inflates. Detect it by comparing against the Sales table, as in example 07.
  • Flattening and losing the Date table. Time intelligence may behave unexpectedly on raw date columns. Test with the DAX query view, and relate a proper Date table.
  • Assuming a flat table is smaller or faster. It may or may not be. Compare VertiPaq Analyzer statistics and Server Timings on both designs.
  • Keeping unused high-cardinality columns. IDs, timestamps, and free text can be costly. Look at the largest columns in VertiPaq Analyzer and remove the ones no report uses.
  • Adding bi-directional or many-to-many relationships to "fix" a star. These change how filters propagate and can add ambiguity. Fix the grain or the keys first, and test any change. Behavior can depend on your Power BI version and the SSAS compatibility level.
  • Unmatched keys creating a blank row. You see (Blank) in a dimension visual. Detect it with example 16.
  • Trusting a model without reconciling. Always compare totals against the source, as in examples 04 and 20.

Best Practices Checklist

  1. Model at the lowest useful grain. You can always aggregate up, but you cannot recover detail you threw away.
  2. Keep descriptive attributes in dimensions. They are stored once and fixed in one place.
  3. Use one dedicated, marked Date table. Time intelligence depends on unique, contiguous dates.
  4. Keep header-level amounts on the header table. This prevents overcounting at the line grain.
  5. Remove unused and high-cardinality columns. They drive column size without adding value.
  6. Fix keys and data quality at the source. Unmatched keys create blank rows and quiet errors.
  7. Reuse base measures. One definition of [Total Sales] keeps every report consistent.
  8. Measure before and after changes. VertiPaq Analyzer and DAX Studio show what really changed.
  9. Validate totals between designs. A reconciliation query catches duplication and dropped rows early.
  10. Document model decisions. Future you will need to know why a column or relationship exists.

Quick Reference

SituationRecommended approach
Small, one-off analysis with one grainA flat table can be acceptable; reconcile totals
Several fact tables sharing customers or productsStar schema with conformed dimensions
Freight or TaxAmount per orderKeep on the order header table
Year-to-date or previous-year comparisonsMarked Date table related to the fact
Order date and ship date both neededOne Date table with an inactive relationship and USERELATIONSHIP
Model feels large or slowMeasure with VertiPaq Analyzer and Server Timings first
(Blank) appears in a dimension visualFind and fix unmatched keys

Frequently Asked Questions

Is a flat table always bad in Power BI?

No. For a small model with a single grain and no header-level amounts, it can work well. It becomes risky when you mix grains, need time intelligence, or share dimensions across facts. Always reconcile the totals.

Is a star schema always faster?

No. Speed and size depend on your model, the cardinality of its columns, and the queries you run. A star schema is more predictable for correctness and reuse, but you should measure performance on your own data.

Do I need a Date table if I use a flat table?

For reliable time intelligence, yes, a marked Date table related to your date column is the supported approach. Raw date columns on a fact table lack unique, gap-free dates, so test carefully if you skip it. Check the current documentation for how auto date/time behaves in your version.

How do I check my model size and column cardinality?

Use VertiPaq Analyzer through DAX Studio or Tabular Editor to see sizes and cardinality per table and column. You can also run simple DAX queries with DISTINCTCOUNT, as in example 05. Compare the results before and after each change.

Conclusion

The choice between a star schema and a flat table is not about a universal speed winner. It is about grain, correctness, and measurement. Here are the key takeaways:

  • Cardinality drives column size, so watch high-cardinality columns in either design.
  • Flattening mixes grains, and header-level amounts like Freight overcount when summed on line rows.
  • A marked Date table supports time intelligence and role-playing dates.
  • Never claim one design is always smaller or faster. Measure with VertiPaq Analyzer, Server Timings, and Performance Analyzer.
  • Reconcile totals between designs before you trust either one.

Want more practical Power BI, DAX, and data modeling guides? Visit exceltobi.com for more articles and tutorials.

Related reading: my earlier articles on CALCULATE, calculated tables and columns, and explicit measures.

Monday, November 16, 2026

Star Schema for Power BI: A Beginner’s Guide to Better Data Models

When a Power BI report is slow, shows odd totals, or needs hugely complicated DAX, the cause is very often not the DAX at all. It's the data model. And the single most valuable thing you can do for your model is to shape it as a star schema.

It's the design recommended by Microsoft and by virtually every Power BI professional, and once you understand it, a lot of DAX suddenly becomes simpler.

What you'll learn

  • What a star schema is, and the difference between fact and dimension tables
  • Why Power BI works best with this design
  • How to turn a single flat table into a star schema using Power Query
  • Rules for relationships, keys and the Date table
  • The most common modeling mistakes

The problem

If you're coming from Excel, you probably keep everything in one big table: one row per sale, with the product name, category, customer, city, country and amounts all side by side.

OrderID Date Product Category Customer Country Amount
1001 2026-01-05 Road Bike Bikes Asha India 1,200
1002 2026-01-06 Road Bike Bikes Ravi India 1,200
1003 2026-01-06 Helmet Accessories Asha India 45

This works in a spreadsheet, but notice how much text is repeated. "Bikes", "India" and "Asha" are stored again on every row. With millions of rows, this causes problems:

  • Larger, slower models, because the same descriptive text is stored over and over
  • Harder DAX, because a date table, product list or customer list doesn't exist as a separate thing to filter
  • Unreliable results, for example when counting customers or products from a table that contains each one many times

The solution

What is a star schema?

A star schema splits your data into two kinds of tables:

  • Fact table: one row per event or transaction (a sale, an order line, a click). It contains numbers you measure (quantity, amount) and keys that point to the dimension tables. It is long and narrow.
  • Dimension tables: descriptive lists of the things you slice and filter by: products, customers, dates, stores. Each has one row per item and a unique key. They are short and wide.

Draw the fact table in the middle with the dimensions around it and you get a star:


                 Date
                  |
                  |  1
                  |
  Product ------- Sales ------- Customer
        1        *   *        1
                  |
                  |  *
                  |
                 Store

Each "1" is a dimension (one row per item) and each "*" is the fact table (many rows per item). So one product has many sales, one customer has many sales, and so on.

A concrete example

Table Type Columns
Sales Fact OrderDate, ProductKey, CustomerKey, StoreKey, Quantity, UnitPrice, SalesAmount
Product Dimension ProductKey, ProductName, Category, Subcategory, Brand
Customer Dimension CustomerKey, CustomerName, City, Country
Store Dimension StoreKey, StoreName, Region
Date Dimension Date, Year, Quarter, Month, Month Number

Turning a flat table into a star: step by step

Suppose you've loaded one flat query called FlatSales. In Power Query:

  1. Create the dimension. Right-click FlatSales and choose Reference. Keep only the product columns, then remove duplicates (Home → Remove Rows → Remove Duplicates). Rename the query Product.
  2. Repeat for Customer, Store and any other descriptive group.
  3. Slim down the fact table. In FlatSales keep only the key columns and the numeric columns, then rename it Sales.
  4. Add the Date table.
  5. Close and apply, then build relationships in Model view.

The dimension query is just a column selection followed by removing duplicates. In M, that looks like:

let
    Source = FlatSales,
    ProductColumns = Table.SelectColumns(
        Source,
        {"ProductID", "ProductName", "Category", "Subcategory"}
    ),
    Product = Table.Distinct(ProductColumns)
in
    Product

Make sure each dimension has a unique key column. If your data has no natural ID, add an Index column in Power Query and use it as the key in both the dimension and the fact table.

Create the relationships

In Model view, connect each dimension key to the matching key in the fact table (Product[ProductKey] to Sales[ProductKey], and so on). Every relationship should be one-to-many (dimension on the "one" side), with filtering set to single direction.

The payoff: your DAX stays simple. This one measure works with any slicer, whether it's a product, customer, store or date:

Total Sales = SUM ( Sales[SalesAmount] )

How it works

Why Power BI loves star schemas

  • Filters flow in one direction. When you select "Bikes" in a Product slicer, the filter travels from the Product table (the "one" side) down to Sales (the "many" side). Your measures then see only bike sales. It's predictable, and it's how every DAX filter pattern is designed to work.
  • Better compression. Power BI stores each column separately and compresses repeated values. Descriptive text lives once per product or customer in a small dimension instead of repeating on every sales row, which typically means smaller, faster models.
  • Simpler measures. Counting customers, listing products without sales, or building time comparisons all work naturally when each concept has its own table.
One flat table Star schema
Repeated text On every row Once per dimension row
Model size and speed Larger and slower on big data Smaller and faster
Slicers and filters Built from the big table Built from small dimensions
DAX complexity Often needs workarounds Simple, standard patterns
Reuse for new fact tables Hard Easy: share the same dimensions

Design rules checklist

  • Facts: numeric measures plus foreign keys. No long descriptive text.
  • Dimensions: a unique key, plus the descriptive columns people filter and group by.
  • Relationships: one-to-many, single direction, from dimension to fact.
  • Keys: same data type on both sides (integers are best). Hide key columns from the report view.
  • One Date table, marked as a date table, shared by all facts.
  • Flatten snowflakes. If Product links to Subcategory, which links to Category, merge them into one Product dimension.
  • Hide the fact table's raw columns and expose measures instead.

When one date column isn't enough

Often a fact table has several dates, such as OrderDate and ShipDate. Don't create a second Date table. Relate both to the same one: one relationship stays active (usually OrderDate), the other is inactive. Then activate it inside a measure only when you need it:

Sales by Ship Date =
CALCULATE (
    [Total Sales],
    USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)

This pattern is called a role-playing dimension: the same Date table plays a different role depending on the measure.

Common mistakes

  • Keeping everything in one flat table. The most common beginner model. It works on small data and then slows down as it grows.
  • Leaving dimensions "snowflaked". Chains of lookup tables (Product → Subcategory → Category) add relationship hops and confuse users. Merge them into one dimension.
  • Setting bidirectional filtering everywhere. It seems to fix filtering problems, but it can create ambiguous paths, slow performance and unexpected results. Keep single direction unless you have a specific reason.
  • Linking fact tables directly to each other. If you have Sales and Budget, connect both to shared dimensions (Date, Product), not to each other.
  • Duplicate or blank keys in a dimension. A dimension key must be unique. Duplicates break the one-to-many relationship, and keys in the fact table that have no match show up under a "(Blank)" row in your visuals.
  • Mismatched data types on keys. A text key on one side and a number on the other will not relate correctly. Make sure both sides use the same type.

Key takeaways

  • A star schema has one fact table (events and numbers) surrounded by dimension tables (descriptions).
  • Relationships should be one-to-many, with filters flowing from dimensions to the fact table.
  • Split flat tables into facts and dimensions in Power Query, not in DAX.
  • A good model makes your DAX shorter, your reports faster and your numbers more trustworthy.

Related posts

Not sure how to split your own data? Describe your columns in the comments and I'll suggest which ones belong in the fact table and which in dimensions.

Friday, November 13, 2026

ALL vs REMOVEFILTERS in DAX: Differences and When to Use

You open a colleague's measure and spot REMOVEFILTERS where you would have typed ALL. Is it just ALL with a new name? You swap one for the other, refresh the report, and your "percent of total" now shows 100% on every row. Or worse, the grand total looks right but the rows are off.

That moment is why this comparison matters. The two functions overlap heavily, but they are not identical, and the differences hide in places like iterators, variables and filters that arrive from related tables. This article covers ALL vs REMOVEFILTERS from the ground up: syntax, behavior, pros and cons, pitfalls, best practices and 20 worked examples.

One note before we start. Anything that depends on your Power BI version, your SSAS compatibility level, or evaluation details I can't guarantee is flagged. Wherever I say "test it", open the DAX query view and run the query yourself. Ten minutes of testing beats an hour of guessing.

The Sample Data Model Used in This Article

Every example uses the same small star schema, so you can focus on the DAX rather than the data.

  • Customer (dimension): CustomerKey, CustomerName, Segment, City, State, Country, Region and more.
  • Product (dimension): ProductKey, ProductName, Category, Subcategory, Brand, Color, UnitCost, ListPrice and more.
  • Date (dimension, marked as the date table): Date, Year, Quarter, MonthName, FiscalYear and more.
  • Sales (fact, one row per order): SalesOrderID, CustomerKey, OrderDate, ShipDate, SalesChannel, Freight, TaxAmount.
  • Sales Order Details (fact, one row per product per order): SalesOrderLineID, SalesOrderID, ProductKey, Quantity, UnitPrice, DiscountPct, SalesAmount, TotalCost.

All relationships are one-to-many with single-direction filtering. Customer and Date filter Sales, and Sales filters Sales Order Details. Product filters Sales Order Details directly. Header-level amounts such as Freight and TaxAmount are not filtered by Product, so never slice them by Product columns.

The base measures are used exactly as defined:

Total Sales = SUM ( 'Sales Order Details'[SalesAmount] )

Sales All Products =
CALCULATE ( [Total Sales], REMOVEFILTERS ( Product ) )

% of All Products =
DIVIDE ( [Total Sales], [Sales All Products] )

Other base measures, such as [Total Cost], [Total Profit] and [Order Count], follow the same conventions. Any extra measure or calculated table is named before it is used.

Concepts: Filter Context and "Removing a Filter"

What is filter context?

Filter context is the set of filters active when a measure is evaluated. Slicers, rows and columns in a visual, page filters and filter arguments in CALCULATE all contribute. Think of it as the filter chips at the top of a report: Category = Bikes, Year = 2025, Country = Germany. The measure only "sees" the rows that survive all those chips.

What does "removing a filter" mean?

Removing a filter means clearing the chips for a table or column before the calculation runs. If a row in your visual says Category = Bikes, a measure that clears the Category filter calculates as if the row had no Category chip at all. That is how you build a denominator: the number for this row divided by the number for everything.

ALL in one paragraph

ALL is a table function. It returns every row of a table, or every distinct value of one or more columns, ignoring existing filters. Because it returns a table, you can use it in two ways. Inside CALCULATE it acts as a filter modifier that clears filters. Anywhere else it is an ordinary table expression you can iterate, count, store in a variable or pass to other table functions.

REMOVEFILTERS in one paragraph

REMOVEFILTERS is a CALCULATE filter modifier. It clears filters from a table, from specific columns, or, with no arguments, from the whole filter context. It does not return a table, and that single fact is the source of most of the practical differences.

How they are typically used

Both show up in denominators: percent of total, share of parent, grand totals and rankings. The pattern is always the same. Evaluate the measure in the current context for the numerator, then evaluate it again with some filters cleared for the denominator.

Syntax

ALL

ALL ( [table | column [, column [, ...]]] )
  • Table form: ALL ( Product ) returns all rows of the table, ignoring filters, and clears every column filter on that table when used in CALCULATE.
  • Column form: ALL ( Product[Category] ) returns the distinct values of that column. You can list several columns, and they must all come from the same table.
  • No-argument form: ALL () clears filters on every table in the model. It is limited to use as a CALCULATE filter modifier.
  • Arguments must be references to an existing table or column, not expressions. Check the current documentation for any further restrictions in your version.

REMOVEFILTERS

REMOVEFILTERS ( [table | column [, column [, ...]]] )
  • Table form: REMOVEFILTERS ( Product ) clears all filters on that table.
  • Column form: REMOVEFILTERS ( Product[Category] ) clears the filter on one or more columns of the same table.
  • No-argument form: REMOVEFILTERS () clears all filters across the model.
  • It is valid only as a filter modifier in CALCULATE or CALCULATETABLE. It cannot return a table for other functions to use.

Version support

REMOVEFILTERS is newer than ALL. I am not going to quote a specific release, so check that your Power BI Desktop version, service or SSAS Tabular instance supports it. If you maintain models on older SSAS versions or compatibility levels, check support before standardizing on it.

Key Behavioral Differences

1. Return value

ALL returns a table, so it works anywhere a table is expected: SUMX ( ALL ( ... ), ... ), COUNTROWS ( ALL ( ... ) ), ADDCOLUMNS ( ALL ( ... ), ... ), or VAR t = ALL ( ... ). REMOVEFILTERS returns no table, so in any of those places it is invalid. This is the one situation where you have no choice.

2. Behavior as a CALCULATE modifier

When both are used purely to clear filters inside CALCULATE, they produce the same filter-clearing effect. The real difference is readability. REMOVEFILTERS says "I only want to clear filters", while ALL leaves the reader wondering whether a table is being used somewhere. In a code review, REMOVEFILTERS communicates intent faster.

3. Table vs column scope

Clearing a table removes filters on all its columns. Clearing a column removes the filter on that column only, and other columns of the same table stay filtered. Filters on other tables are not touched by either, which leads to the next point.

4. Filters that come from related tables

Clearing a fact table does not clear filters sitting on a related dimension. Suppose a visual filters Customer[Country] = Germany. If you clear the Sales table, the filter on Customer is still there. It propagates down through the relationship again, so the result is still German sales. Clear the table that actually holds the filter. Examples 15 and 16 demonstrate this, and you should run them against your own model.

5. The blank row

If a relationship has fact rows with no matching dimension row, Power BI shows a blank member. ALL includes that blank member in what it returns, and ALLNOBLANKROW excludes it. If you care about this edge case, test it with your data, because the effect on counts and rankings depends on whether your model has unmatched keys.

6. Interaction with other CALCULATE filters and row-level security

When CALCULATE contains both clearing modifiers and new filter arguments, the documented behavior is that clearing is applied before the new filters. Check the current CALCULATE documentation for the full evaluation order and test your pattern (example 17). For row-level security (RLS), the engine enforces security filters and a DAX modifier is not a way around them, so a denominator only covers rows the user may see. Verify this with "View as" in your own environment before relying on it.

Comparison Table

AspectALLREMOVEFILTERS
PurposeReturn all rows or distinct values, ignoring filters; also clears filters in CALCULATEClear filters only
Return typeTable (except the no-argument form, which is a modifier only)No table
Usable as CALCULATE filter modifierYesYes (also CALCULATETABLE)
Usable as table expression (iterators, variables)Yes, with a table or column argumentNo
Arguments acceptedOne table, or one or more columns from the same tableOne table, or one or more columns from the same table
No-argument formALL (), CALCULATE modifier only, clears all filtersREMOVEFILTERS (), clears all filters
Effect on filter contextAs a modifier, clears the specified filters; as a table expression, does not itself change contextClears the specified filters
Readability / intentAmbiguous: could be clearing or returning a tableClear: only clearing
Typical useDenominators, iterating all values, ranking sets, calculated tablesDenominators and "grand total" logic inside CALCULATE
Main limitationIntent is less obvious in modifier useCannot be used where a table is required

Pros, Cons and Limitations

ALL

Pros

  • Works both as a CALCULATE modifier and as a table expression.
  • Available in older versions of Power BI and SSAS, so it appears in a lot of existing code.
  • Required for iterating over "all values", for calculated tables and for ranking sets.

Cons and limitations

  • In a CALCULATE argument, a reader cannot tell at a glance whether it only clears filters.
  • Accepts only a table or columns of one table, not expressions.
  • Easy to over-clear when used with a table or with no arguments.

REMOVEFILTERS

Pros

  • The name states the intent, which makes measures easier to review.
  • It cannot be mistaken for a table function, so it signals "modifier only".
  • Works in both CALCULATE and CALCULATETABLE.

Cons and limitations

  • Cannot be used in iterators, variables or as an argument to table functions.
  • Newer, so check version support for older SSAS environments.
  • Like ALL, it can over-clear if you pass a whole table or nothing.

On performance: I make no speed claims for either function. Results depend on your model and your query, so measure when it matters.

Which One Should You Use?

Decision guide

  1. Do you need a table (to iterate, count, store in a VAR or pass to another table function)? Use ALL.
  2. Do you only need to clear filters inside CALCULATE or CALCULATETABLE? Use REMOVEFILTERS.
  3. Do you want to clear everything on a table except certain columns? Consider ALLEXCEPT.
  4. Should the denominator respect slicers and outer filters but ignore the visual's own rows? Consider ALLSELECTED and test it.
  5. Do you want to add a filter without replacing the existing one on that column? Consider KEEPFILTERS.
  6. Do you need the values currently visible in the context? That is the job of VALUES, not a clearing function.

Rule of thumb

If you need a table, use ALL. If you only need to clear filters, use REMOVEFILTERS.

20 Examples on the Sample Data Model

Beginner: ALL and REMOVEFILTERS as Filter Modifiers

Example 01: Clearing filters on the Sales table with ALL

Type: measure. New measure: [Sales Ignoring Sales Filters (ALL)].

Sales Ignoring Sales Filters (ALL) =
CALCULATE ( [Total Sales], ALL ( Sales ) )

This clears every filter that sits directly on the Sales table, such as SalesChannel. It does not necessarily give you the model's grand total, because filters on Customer, Date or Product are untouched. Customer and Date filters flow into Sales through relationships, and Product filters Sales Order Details directly. Despite the name "grand total", this measure only ignores filters placed on Sales columns. That is the lesson: the function clears the table you name, not the whole model.

Example 02: The same result with REMOVEFILTERS

Type: measure. New measure: [Sales Ignoring Sales Filters (REMOVEFILTERS)], shown next to Example 01.

Sales Ignoring Sales Filters (REMOVEFILTERS) =
CALCULATE ( [Total Sales], REMOVEFILTERS ( Sales ) )

Put both measures in a table visual and the two columns match. Both clear the same filters, so the choice is about intent. REMOVEFILTERS tells the next developer you are only clearing, with no table needed. The lesson: in a CALCULATE argument, the two are interchangeable in effect.

Example 03: Percent of total across all products

Type: measure. New measure: [Sales % of All Products].

Sales % of All Products =
DIVIDE (
    [Total Sales],
    CALCULATE ( [Total Sales], ALL ( Product ) )
)

The numerator is the sales for the current product filters, and the denominator is sales with every Product filter removed. DIVIDE protects against a zero or blank denominator. The base measure [% of All Products] does the same job using REMOVEFILTERS, so the two should agree. The lesson: clear the dimension that defines the "whole", which here is Product, not Sales.

Example 04: Clearing a single column

Type: two measures. New measures: [Sales All Categories (ALL)] and [Sales All Categories (REMOVEFILTERS)].

Sales All Categories (ALL) =
CALCULATE ( [Total Sales], ALL ( Product[Category] ) )

Sales All Categories (REMOVEFILTERS) =
CALCULATE ( [Total Sales], REMOVEFILTERS ( Product[Category] ) )

Both clear only the Category filter. If a slicer filters Product[Brand] or Product[Color], those filters remain and still shape the result. This is what makes the column form narrower than the table form. The lesson: clearing a column leaves the other columns of that table filtered.

Example 05: All customers regardless of country

Type: measure. New measure: [Sales All Countries].

Sales All Countries =
CALCULATE ( [Total Sales], REMOVEFILTERS ( Customer[Country] ) )

This clears only the country filter. A filter on Customer[Segment] or Customer[City] still applies, as do Date and Product filters. It is useful for comparing one country against the total within the same segment. The lesson: pick the column that defines the comparison, not the whole table.

Intermediate: ALL as a Table Function

Example 06: How many categories exist?

Type: measure. New measure: [Category Count All].

Category Count All =
COUNTROWS ( ALL ( Product[Category] ) )

ALL returns the distinct categories regardless of any filter, and COUNTROWS counts them. The result does not change when a slicer is moved. If your model has unmatched keys, the blank member may be counted, so test it. The lesson: this needs a table, so REMOVEFILTERS cannot do it.

Example 07: ALL as the table to iterate

Type: measure. New measure: [Sales From Large Countries]. The threshold is illustrative.

Sales From Large Countries =
VAR LargeCountryThreshold = 1000000
RETURN
    SUMX (
        FILTER (
            ALL ( Customer[Country] ),
            [Total Sales] > LargeCountryThreshold
        ),
        [Total Sales]
    )

The iteration covers every country, because ALL ignores any country filter. For each country, [Total Sales] is evaluated and kept only if it passes the threshold, then the survivors are summed. Other filters, such as Date or Product, still apply. REMOVEFILTERS cannot be used here because SUMX and FILTER need a table. The lesson: iteration needs a table, so you need ALL.

Example 08: A VAR holding ALL in a ranking

Type: measure. New measure: [Country Sales Rank].

Country Sales Rank =
VAR AllCountries = ALL ( Customer[Country] )
RETURN
    IF (
        HASONEVALUE ( Customer[Country] ),
        RANKX ( AllCountries, [Total Sales] )
    )

The variable stores every country, ignoring the current country filter. RANKX ranks the current country against all of them by [Total Sales]. HASONEVALUE avoids showing a meaningless rank on total rows. A named variable keeps the logic readable. The lesson: a variable can hold a table, so ALL fits and REMOVEFILTERS does not.

Example 09: A calculated table of categories

Type: calculated table. New table: 'All Categories'.

'All Categories' = ALL ( Product[Category] )

This creates a one-column table of distinct categories. It is a persistent table calculated at data refresh, so it does not respond to slicers or report filters. That is useful for a disconnected slicer or a reference list. It also means the table will not update until the next refresh. The lesson: calculated tables are evaluated without report filters, and ALL is the right tool for building one.

Example 10: ADDCOLUMNS around ALL

Type: DAX query (EVALUATE). No new measures or tables.

EVALUATE
ADDCOLUMNS (
    ALL ( Product[Category] ),
    "Total Sales", [Total Sales]
)
ORDER BY Product[Category]

The query lists every category and adds a column with its sales. ADDCOLUMNS creates a row context for each category, and the measure turns it into a filter automatically. Categories with no sales still appear, because ALL does not filter by the fact table. This is a quick way to check your data by category. The lesson: ALL gives a complete list that does not depend on what has sales.

Intermediate: Parent/Child Share and Partial Clearing

Example 11: Share of category

Type: measure. New measure: [Sales % of Category].

Sales % of Category =
VAR CategorySales =
    CALCULATE (
        [Total Sales],
        REMOVEFILTERS ( Product[Subcategory], Product[ProductName] )
    )
RETURN
    DIVIDE ( [Total Sales], CategorySales )

The variable clears Subcategory and ProductName but keeps the Category filter. In a matrix with Category, Subcategory and ProductName, each row is divided by its category's sales. Other Product columns, such as Brand or Color, stay filtered if they are in the context. List every lower-level column your report uses. The lesson: partial clearing is column-by-column, and you must name what you want cleared.

Example 12: The same share with ALLEXCEPT

Type: measure, for contrast. New measure: [Sales % of Category (ALLEXCEPT)].

Sales % of Category (ALLEXCEPT) =
VAR CategorySales =
    CALCULATE (
        [Total Sales],
        ALLEXCEPT ( Product, Product[Category] )
    )
RETURN
    DIVIDE ( [Total Sales], CategorySales )

ALLEXCEPT clears every filter on Product except the one on Category. That includes Brand, Color and any other Product column, not just the hierarchy levels. If the report has a Brand slicer, this denominator ignores it, while Example 11 would keep it. Neither is wrong, but they answer different questions. The lesson: ALLEXCEPT is broader than listing the levels you want to clear.

Example 13: Percent of grand total with REMOVEFILTERS ()

Type: measure. New measure: [Sales % of Grand Total].

Sales % of Grand Total =
DIVIDE (
    [Total Sales],
    CALCULATE ( [Total Sales], REMOVEFILTERS () )
)

With no arguments, REMOVEFILTERS clears every filter in the model, including Date, Customer and Product slicers. The denominator is then the sales of the entire model, regardless of what the user selected. That may be exactly what you want for a "share of company" metric. It is also the easiest way to surprise report users who expect slicers to apply. The lesson: the no-argument form clears much more than most measures need.

Example 14: Contrast with ALLSELECTED

Type: measure, as a contrast example. New measure: [Sales % of Selected Products].

Sales % of Selected Products =
DIVIDE (
    [Total Sales],
    CALCULATE ( [Total Sales], ALLSELECTED ( Product ) )
)

ALLSELECTED removes the filters coming from the visual's own rows and columns, but keeps filters from outside it, such as a slicer on Category. If the user selects two categories in a slicer, the denominator is the sales of those two categories, so the percentages add up to 100% within the selection. ALL or REMOVEFILTERS would use all products. ALLSELECTED has subtle behavior in complex visuals, so test it in your report. The lesson: choose between "percent of everything" and "percent of what the user selected".

Advanced: Pitfalls in Practice

Example 15: Clearing a fact table while a dimension filter remains

Type: DAX query (EVALUATE). No new measures.

EVALUATE
ROW (
    "Germany Sales",
        CALCULATE ( [Total Sales], Customer[Country] = "Germany" ),
    "Germany With Sales Table Cleared",
        CALCULATE (
            [Total Sales],
            Customer[Country] = "Germany",
            REMOVEFILTERS ( Sales )
        ),
    "All Sales", [Total Sales]
)

The first two columns return the same value. The country filter lives on Customer, and clearing Sales does not touch it. The filter flows from Customer to Sales and then to Sales Order Details, so German sales remain. This holds because of the model's one-to-many, single-direction relationships. The lesson: clearing the fact table is not the same as clearing the dimension that holds the filter.

Example 16: Clearing the dimension instead

Type: DAX query (EVALUATE). No new measures.

EVALUATE
CALCULATETABLE (
    ROW (
        "Germany Sales", [Total Sales],
        "All Customers Sales",
            CALCULATE ( [Total Sales], REMOVEFILTERS ( Customer ) )
    ),
    Customer[Country] = "Germany"
)

The outer CALCULATETABLE applies the country filter, so the first column shows German sales. The second column clears the Customer table, so the filter is gone and the result is sales for all customers. This is the corrected version of Example 15. If a cleared filter seems to keep applying, look at which table actually holds it. The lesson: clear the table the filter sits on.

Example 17: Clearing a column and then filtering in the same CALCULATE

Type: measure. New measure: [Sales Bikes Only]. "Bikes" is a sample value.

Sales Bikes Only =
CALCULATE (
    [Total Sales],
    REMOVEFILTERS ( Product[Category] ),
    Product[Category] = "Bikes"
)

The intended result is sales for the Bikes category whatever category the row or slicer says. The documented behavior is that clearing happens before the new filter is applied, but check the current CALCULATE documentation and test in the DAX query view. For this exact case the clearing is arguably redundant, because a filter on a column replaces the existing filter on that column. It becomes useful when you clear a wider scope, such as REMOVEFILTERS ( Product ), and then set one column. The lesson: be explicit, and test evaluation order.

Example 18: KEEPFILTERS as the opposite behavior

Type: measure. New measure: [Sales Bikes Within Selection]. I combine it with a filter argument rather than a clearing modifier, since pairing it with REMOVEFILTERS would defeat its purpose.

Sales Bikes Within Selection =
CALCULATE (
    [Total Sales],
    KEEPFILTERS ( Product[Category] = "Bikes" )
)

Without KEEPFILTERS, the Bikes filter would replace whatever the slicer selected. With it, the filter intersects with the existing selection. If the slicer has Clothing selected, the result is blank, because Clothing and Bikes do not overlap. If Bikes and Clothing are both selected, you get Bikes. The lesson: modifiers decide whether a filter replaces or respects the existing selection.

Example 19: Counting Sales rows with ALL and with REMOVEFILTERS

Type: two measures. New measures: [Sales Row Count (ALL)] and [Sales Row Count (REMOVEFILTERS)].

Sales Row Count (ALL) =
COUNTROWS ( ALL ( Sales ) )

Sales Row Count (REMOVEFILTERS) =
CALCULATE ( COUNTROWS ( Sales ), REMOVEFILTERS ( Sales ) )

The first uses ALL as a table expression and returns the total number of rows in Sales. The second clears filters on Sales before counting. With no Customer or Date filter they match. When a Customer or Date filter is active, the second can be smaller, because those filters still reach Sales through relationships, while the first ignores context entirely. Verify this in your own model. The lesson: "ALL as a table" and "REMOVEFILTERS as a modifier" are not always the same, so test both.

Example 20: A reconciliation query for a denominator

Type: DAX query (EVALUATE). No new measures.

EVALUATE
SUMMARIZECOLUMNS (
    Product[Category],
    "Category Sales", [Total Sales],
    "All Products Sales", [Sales All Products],
    "All Filters Removed Sales",
        CALCULATE ( [Total Sales], REMOVEFILTERS () ),
    "Percent of All Products", [% of All Products]
)
ORDER BY Product[Category]

Each row shows the category total, the product-cleared denominator, the all-filters-removed total and the percentage. The denominator columns should be identical on every row, and the percentages should add up to 100%. Compare the denominator to a simple [Total Sales] with no filters. If they differ, some other filter, such as RLS or a hidden page filter, is shaping the numbers. The lesson: always reconcile a denominator before trusting it.

Common Pitfalls

  • Clearing too much. ALL ( Table ) and REMOVEFILTERS () wipe filters the report author may have wanted to keep. Detect it: add a slicer and see whether the denominator ignores it.
  • Clearing the wrong table. Clearing a fact table leaves dimension filters in place (Examples 15 and 16). Detect it: compare the result against the unfiltered total in a DAX query.
  • Using REMOVEFILTERS where a table is needed. In iterators, variables and table-function arguments, it is invalid. Detect it: the measure fails to validate; switch to ALL.
  • Assuming ALL ( Table ) and ALL ( Table[Column] ) behave the same. The table form clears every column, while the column form leaves other columns filtered. Detect it: add a slicer on another column of that table and compare.
  • Confusing ALL with ALLSELECTED. "Percent of total" ignores slicers with ALL, which may not be what users expect. Detect it: change a slicer and see whether the denominator moves.
  • Trusting a denominator without reconciling it. Detect it: run a query like Example 20 and compare to a simple [Total Sales].

Behavior around the blank row, RLS and evaluation order can depend on your version, SSAS compatibility level and model. When in doubt, test and check the current documentation.

Best Practices

  1. Use REMOVEFILTERS to clear and ALL to return a table. The name then tells the reader what the code does.
  2. Clear the narrowest scope. A column rather than a table, and a table rather than the whole model, avoids removing filters you wanted.
  3. Build denominators as named variables. A name like CategorySales explains the logic better than a nested CALCULATE.
  4. Reuse base measures. One definition of [Total Sales] means a fix applies everywhere.
  5. Use DIVIDE for ratios. It handles zero and blank denominators without errors.
  6. Test in the DAX query view. Compare with a simple total before you build visuals on top.
  7. Name measures consistently. Follow patterns such as [Sales % of Category] so the model is searchable.
  8. Check relationships and filter direction. When a "cleared" filter still applies, the cause is usually which table holds it.
  9. Comment non-obvious clearing logic. A one-line comment saves the next person from guessing.
  10. Format DAX consistently. Consistent layout makes the filter logic easy to review.

Quick Reference

SituationRecommended approach
Percent of all productsREMOVEFILTERS ( Product ) inside CALCULATE
Iterate over all values of a columnALL ( Table[Column] ) as the table argument
Count distinct values ignoring filtersCOUNTROWS ( ALL ( Table[Column] ) )
Share of parent, keeping a higher levelREMOVEFILTERS on lower-level columns, or ALLEXCEPT
Percent of what the user selectedALLSELECTED, tested in your visual
Add a filter without replacing the existing oneKEEPFILTERS
Filter still applies after clearingClear the table that holds the filter
Validate a denominatorReconciliation query with SUMMARIZECOLUMNS

FAQ

Is REMOVEFILTERS a replacement for ALL?

Only partly. As a CALCULATE modifier, the two clear filters the same way, and REMOVEFILTERS states the intent more clearly. But REMOVEFILTERS cannot return a table, so it cannot replace ALL in iterators, variables or calculated tables.

Is ALL deprecated?

NO. ALL is a standard DAX function with uses that REMOVEFILTERS cannot cover. Check the current Microsoft documentation for your product version.

Can I use REMOVEFILTERS outside CALCULATE?

It is documented as a filter modifier for CALCULATE and CALCULATETABLE, not as a general table function. Treat it as invalid anywhere a table is expected, and check the current documentation if you are unsure about a specific context.

Is REMOVEFILTERS faster than ALL?

Performance depends on the model and the query, so if it matters, measure both versions on your own data.

Conclusion: Key Takeaways

  • ALL returns a table. REMOVEFILTERS only clears filters.
  • Inside CALCULATE, both clear filters in the same way, and REMOVEFILTERS reads more clearly.
  • Only ALL works in iterators, variables and calculated tables.
  • Clearing a fact table does not clear filters held by a related dimension.
  • Clear the narrowest scope, and reconcile every denominator against a simple total.
  • Rule of thumb: need a table, use ALL; only clearing, use REMOVEFILTERS.

Want more DAX and data modeling guides like this one? Visit exceltobi.com for practical tutorials on Power BI, DAX, data modeling and SSAS Tabular.

Related reading: my earlier articles on CALCULATE, calculated tables and columns, and explicit measures.

Wednesday, November 11, 2026

VALUES vs DISTINCT in DAX: What Each Returns, How They Differ, and When to Use Which

A developer rewrites a measure, swapping VALUES for DISTINCT. The logic looks identical, but the category count drops from 9 to 8. Nobody touched the data. Nothing errors. One row has simply vanished.

Or you are a report author. A slicer on a dimension column shows an unlabeled entry at the bottom of the list, and clicking it filters the report down to a handful of orders. Where did that blank category come from?

Both stories lead to the same place: the subtle difference between VALUES vs DISTINCT. Most of the time the two functions behave the same, and that is exactly why the difference catches people out. In this article you will learn what each function returns, where they diverge, and how to choose between them. You will also see 20 worked examples you can run in the DAX query view.

The sample data model used in this article

All examples use one model with five tables. Customer, Product and Date are dimensions. Sales holds one row per order. Sales Order Details holds one row per product per order and is the lowest grain.

  • Customer[CustomerKey] filters Sales[CustomerKey].
  • Date[Date] filters Sales[OrderDate] (active) and Sales[ShipDate] (inactive).
  • Sales[SalesOrderID] filters 'Sales Order Details'[SalesOrderID].
  • Product[ProductKey] filters 'Sales Order Details'[ProductKey].

All relationships are one-to-many and single direction. One base measure is used throughout, defined once here:

Total Sales =
SUM ( 'Sales Order Details'[SalesAmount] )

One important assumption: the sample data is clean, so every order line has a matching product. That means the blank row discussed below will not appear unless your own data has unmatched keys. I flag this wherever it matters.

Concepts: what "unique values" means in DAX

A one-column table of distinct entries

When people say "unique values" in DAX, they usually mean a table with one column that lists each distinct entry of a column once. It works like SELECT DISTINCT Category FROM Product in SQL. Think of the guest list at a wedding: the same person might appear on many invitations, but the list of attendees names each person once.

Both functions are table functions that respect filter context

VALUES and DISTINCT both return tables, not single numbers. Both are evaluated in the current DAX filter context. If a slicer limits Product[Category] to one category, then a list of Product[Subcategory] values only contains subcategories within that category. The lists shrink as filters are applied. ALL is the function that ignores filters, and I mention it only to draw that line.

The blank row (unknown member)

This is the heart of the topic, so let us take it slowly. Imagine a fact table row, say an order line, whose ProductKey does not exist in the Product table. The relationship cannot connect that line to any product. The engine still needs somewhere to put that row when you group by a product column. So it adds a special blank row, often called the unknown member, to the dimension table. The unmatched fact rows get attached to that blank row.

This is different from a genuine blank value stored in a column. If Product[Color] is empty for some products, that is simply data: the column contains blanks. The unknown member is not stored anywhere. It is created by the engine because of a relationship violation (the formal name is a referential integrity violation).

The two can look the same in a visual, which is why they get confused. They have different causes and different fixes. A genuine blank is a data question. The unknown member is a relationship or data-load question.

Why this matters

Selecting, counting and testing for a single value are all built on these functions. HASONEVALUE asks whether the filter context holds exactly one distinct value. SELECTEDVALUE returns that value when there is one. According to the documentation, SELECTEDVALUE is equivalent to IF ( HASONEVALUE ( column ), VALUES ( column ), alternateResult ). So VALUES sits underneath the single-value logic you probably already use every day.

Table functions vs measures

A measure returns one value. VALUES and DISTINCT return tables, so you cannot put them directly in a card visual. You use them inside other functions: COUNTROWS, iterators such as SUMX, CALCULATE filter arguments and variables. You can also use them in calculated tables and in DAX queries with EVALUATE.

Syntax of each function

VALUES

VALUES ( <TableNameOrColumnName> )
  • Column form: you pass a column, such as Product[Category]. You get a one-column table of the distinct values visible in the current filter context. The result can also include the blank row described above.
  • Table form: you pass a table name, such as Product. You get the rows of that table in the current filter context. Duplicate rows are kept, which is a difference from DISTINCT.

The documentation describes the argument as a column name or a table name. As far as I know, VALUES does not take an arbitrary table expression such as the output of FILTER. If you need that, check the current documentation for your version, or use the DISTINCT table form.

DISTINCT

DISTINCT ( <ColumnNameOrTableExpression> )
  • Column form: you pass a column. You get a one-column table of its unique values in the current filter context. It does not add the blank row created by a relationship violation.
  • Table form: you pass a table expression. You get the unique rows of that table. This form was added in newer releases of Power BI and SSAS. I will not name a specific release, so check version support in your environment and test it before relying on it.

The practical difference in input: DISTINCT can accept a table expression in its table form, while VALUES takes a table name.

Key behavioral differences

1. The blank row from relationship violations

VALUES can include the unknown member. DISTINCT does not add it. Suppose some order lines carry a ProductKey that is missing from Product. Then VALUES ( Product[Category] ) can return one more row than DISTINCT ( Product[Category] ): the blank row.

The case to be careful about is a column that also holds a genuine blank value. A real blank is just another value, so the column form of both functions returns a blank entry for it.

2. The table form

VALUES ( table ) returns the table's rows in the current filter context and keeps duplicate rows. DISTINCT ( table ) returns unique rows. Every table in the sample model has a unique key, so on a whole table you will not see duplicates. The difference appears with a table expression that discards the key, which only DISTINCT accepts.

3. Filter context

Both respond to it in the same way. Put a slicer on Product[Category] and select one category. A list built from Product[Subcategory] then shows only that category's subcategories. Clear the slicer and the list grows back. Neither function ignores filters.

4. Single-value logic

HASONEVALUE and SELECTEDVALUE are tied to VALUES. HASONEVALUE returns TRUE when exactly one distinct value is in context. SELECTEDVALUE returns that value, or an alternate result otherwise. Note one consequence: if the unknown member is in context together with a real value, VALUES sees two entries, so there is no single value.

5. Counting

There are three ways to count unique values:

  • COUNTROWS ( VALUES ( column ) ) counts the rows of the list, including a blank entry (real or the unknown member).
  • COUNTROWS ( DISTINCT ( column ) ) counts the same list without the relationship-violation blank row. A real blank in the column is still counted as one entry.
  • DISTINCTCOUNT ( column ) counts distinct values and, per the documentation, counts a blank as a value. DISTINCTCOUNTNOBLANK exists if you need to exclude blanks.

6. Lineage and CALCULATE filter arguments

Both column forms are commonly used as filter arguments in CALCULATE. Filter arguments are evaluated in the original filter context, which is the basis for the "preserve the selection" pattern in examples 12 and 13.

7. Calculated tables, DAX queries and measures

Both work in all three places. In a calculated table, the result is computed when the model is refreshed and then stored, so it does not respond to slicers. In a DAX query or a measure, the result is evaluated against the current context.

Comparison table

AspectVALUESDISTINCT
PurposeDistinct values of a column, or rows of a table, in the current contextUnique values of a column, or unique rows of a table expression
Input acceptedA column or a table nameA column, or a table expression
Return typeTableTable
Blank row (unknown member)Can include itDoes not add it
Table-form behaviorRows of the table, duplicates keptUnique rows only
Respects filter contextYesYes
Typical use caseSingle-value tests, iteration, preserving a selectionLists where the unknown member should be excluded; unique rows of an expression
Main limitationThe extra blank row can surprise you; no arbitrary table expressionsHides the unknown member; table form needs a newer release

Pros, cons and limitations

VALUES

Pros

  • Forms the foundation of HASONEVALUE and SELECTEDVALUE logic.
  • Exposes the unknown member, which can reveal a data problem.
  • Works in both column and table form.

Cons and limitations

  • May return a blank row you did not expect.
  • Does not take arbitrary table expressions.
  • When a single value is expected but several exist, it can raise an error.

DISTINCT

Pros

  • Does not add the relationship-violation blank row, so lists are cleaner.
  • The table form accepts a table expression and returns unique rows.

Cons and limitations

  • Can hide a relationship problem, since the unknown member is missing from its output.
  • The table form depends on release support.
  • Totals computed over its list can fall short of the grand total when unmatched rows exist.

Which one should you use?

When to use VALUES

  • You are building or reading single-value logic around HASONEVALUE or SELECTEDVALUE.
  • You want the unknown member included, so totals reconcile.
  • You are iterating or preserving a selection and want the standard idiom.

When to use DISTINCT

  • You want a clean list without the relationship-violation blank row.
  • You need unique rows from a table expression (check version support).

When to use something else

  • ALL: you want to ignore filters.
  • ALLNOBLANKROW: you want all values ignoring filters and without the blank row.
  • DISTINCTCOUNT: you only need a plain unique count.
  • SELECTEDVALUE: you need one selected value.
  • SUMMARIZE: you need a grouped table across several columns.

Rule of thumb: use VALUES when you want to see everything the engine sees, including the unknown member; use DISTINCT when you want only what is stored.

20 examples

Beginner

Example 01: DAX query, basic form of each function

EVALUATE
VALUES ( Product[Category] )
ORDER BY Product[Category]

EVALUATE
DISTINCT ( Product[Category] )
ORDER BY Product[Category]

These two queries list the categories using each function. On the clean sample data they return the same rows. VALUES keeps the table's column name, so the ORDER BY refers to Product[Category]. The pitfall: identical output here does not mean identical output everywhere. A model with unmatched keys can show an extra blank row from VALUES only.

Example 02: Measure, count with VALUES

New measure: [Category Count Values].

Category Count Values =
COUNTROWS ( VALUES ( Product[Category] ) )

This counts the rows in the list of categories visible in the current filter context. With no filters, you get the number of categories. With a slicer on Product[Brand], it counts only categories containing that brand. The lesson: this count includes a blank entry if one exists. It depends on the data and the relationships.

Example 03: Measure, count with DISTINCT

New measure: [Category Count Distinct].

Category Count Distinct =
COUNTROWS ( DISTINCT ( Product[Category] ) )

Place this beside example 02 in a table visual. On clean data both show the same number. They would differ by one if the unknown member were present in context. The lesson: a mismatch between the two is a signal worth investigating, not a bug in either function.

Example 04: Measure, count with DISTINCTCOUNT

New measure: [Category Count DistinctCount].

Category Count DistinctCount =
DISTINCTCOUNT ( Product[Category] )

This is the shortest way to count unique values. It takes a column only, not a table. The documentation says it counts a blank as a value. How it compares with the two counts above for the unknown member is something to confirm yourself. Reconcile all three in the DAX query view.

Example 05: Measure, readable list of countries

New measure: [Countries Listed].

Countries Listed =
CONCATENATEX (
    VALUES ( Customer[Country] ),
    Customer[Country],
    ", ",
    Customer[Country], ASC
)

CONCATENATEX walks the unique countries and joins them into one text string. Because VALUES respects filter context, a slicer on Customer[Segment] shortens the list. The sort arguments keep the output stable. The pitfall: if the unknown member is in context, the list may show an empty entry that looks like a stray comma.

Intermediate: filter context and single-value logic

Example 06: Measure, selected category

New measure: [Selected Category].

Selected Category =
SELECTEDVALUE ( Product[Category], "Multiple" )

When exactly one category is in context, you get its name. Otherwise you get "Multiple". This is equivalent to an IF around HASONEVALUE and VALUES. That is why VALUES is the function to understand first. The lesson: with no slicer, all categories are in context, so you see "Multiple".

Example 07: Measure, single-value test

New measure: [Sales Single Category].

Sales Single Category =
IF (
    HASONEVALUE ( Product[Category] ),
    [Total Sales],
    BLANK ()
)

This shows sales only when exactly one category is in context, and blank otherwise. It is a good guard in a measure that only makes sense for one category. The pitfall: if the unknown member sits next to a real category in context, there are two values and the guard returns blank.

Example 08: Measure, subcategory count with a variable

New measure: [Subcategory Count].

Subcategory Count =
VAR Subcategories = VALUES ( Product[Subcategory] )
RETURN
    COUNTROWS ( Subcategories )

The variable holds the table once, and COUNTROWS counts it. Naming the list makes the measure easier to read and extend. The count follows the filter context, so selecting a category reduces it. The lesson: a variable holds a table as readily as a number.

Example 09: Calculated table, category list

New calculated table: 'Category List'.

Category List =
DISTINCT ( Product[Category] )

This table is persistent. It is computed at refresh and stored in the model. It does not respond to slicers. The output column is named Category. The lesson: a calculated table is a snapshot of the data at refresh time, not a live filtered list.

Example 10: DAX query, ADDCOLUMNS over VALUES

EVALUATE
ADDCOLUMNS (
    VALUES ( Product[Category] ),
    "Total Sales", [Total Sales]
)
ORDER BY Product[Category]

ADDCOLUMNS adds a calculated column to each row of the category list. For each category, [Total Sales] is evaluated in that row's context through context transition. This is a common pattern for a quick summary table. The lesson: iterating over unique values gives one result row per category, not per product.

Intermediate: table forms and filter arguments

Example 11: DAX query, table forms and row counts

EVALUATE
ROW (
    "Values Product Rows", COUNTROWS ( VALUES ( Product ) ),
    "Distinct Product Rows", COUNTROWS ( DISTINCT ( Product ) ),
    "Distinct Category Rows",
        COUNTROWS (
            DISTINCT (
                SELECTCOLUMNS ( Product, "Category", Product[Category] )
            )
        )
)

Product has a unique key, so the first two counts are equal on clean data. The third uses SELECTCOLUMNS to drop the key, which leaves duplicate category rows that DISTINCT removes. VALUES does not accept that expression as input. The table form of DISTINCT depends on your release, so test it in the DAX query view. The lesson: the table forms differ mostly in what input they accept.

Example 12: Measure, preserve the category selection with VALUES

New measure: [Category Sales Ignoring Subcategory].

Category Sales Ignoring Subcategory =
CALCULATE (
    [Total Sales],
    REMOVEFILTERS ( Product ),
    VALUES ( Product[Category] )
)

REMOVEFILTERS clears every Product filter. VALUES then puts back the categories that were visible in the original context. Filter arguments are evaluated in the original context, so selecting one subcategory leaves its category in place. The result is the total for the whole category. The lesson: this is the "keep one filter, drop the others" idiom. Test it on your own model.

Example 13: Measure, same pattern with DISTINCT

New measure: [Category Sales Ignoring Subcategory Distinct].

Category Sales Ignoring Subcategory Distinct =
CALCULATE (
    [Total Sales],
    REMOVEFILTERS ( Product ),
    DISTINCT ( Product[Category] )
)

This is the same pattern for contrast. On clean data, the two measures return the same figures. The difference could appear when unmatched keys are present, since DISTINCT would not carry the unknown member into the filter. The lesson: compare both measures against a total in the DAX query view before choosing.

Example 14: Measure, iterate over unique countries

New measure: [Capped Country Sales].

Capped Country Sales =
SUMX (
    VALUES ( Customer[Country] ),
    MIN ( [Total Sales], 500000 )
)

For each country, the measure takes its sales and caps it at 500,000 (an illustrative threshold). SUMX then adds the capped values. We iterate over unique countries so each one is evaluated exactly once. Iterating over customers would apply the cap per customer, which is a different calculation. The lesson: the iteration grain decides the result.

Advanced and pitfalls in practice

Example 15: DAX query, demonstrating the blank row

EVALUATE
ROW (
    "Values Count", COUNTROWS ( VALUES ( Product[Category] ) ),
    "Distinct Count", COUNTROWS ( DISTINCT ( Product[Category] ) )
)

On the clean Sample Data Model both numbers are the same, because no order line lacks a matching product. A difference of one usually means the unknown member is present. That happens only when fact rows have no matching dimension row. The lesson: a difference here is a data-quality alert, not a function quirk.

Example 16: DAX query, find order lines with no matching product

EVALUATE
ROW (
    "Unmatched Lines",
    COUNTROWS (
        FILTER (
            'Sales Order Details',
            ISBLANK ( RELATED ( Product[ProductKey] ) )
        )
    )
)

For each order line, RELATED looks up the matching product key. When there is no match, it returns blank and the line is counted. A result of zero means the unknown member should not appear. A fact row whose own ProductKey is blank would also be counted, so inspect any hits. The lesson: this is how you find the root cause of an unexpected blank row.

Example 17: Measure, test a VALUES result for blank

New measure: [Is Blank Category Selected].

Is Blank Category Selected =
IF (
    HASONEVALUE ( Product[Category] ),
    ISBLANK ( VALUES ( Product[Category] ) ),
    FALSE ()
)

When one category is in context, VALUES returns a single row, which ISBLANK can test as a scalar. The measure returns TRUE if that single value is blank. The HASONEVALUE guard avoids the multiple-value error. It cannot tell a genuine blank from the unknown member. Test it in the DAX query view.

Example 18: Measure, ALLNOBLANKROW vs ALL

New measures: [Known Categories All] and [Categories All Including Blank].

Known Categories All =
COUNTROWS ( ALLNOBLANKROW ( Product[Category] ) )

Categories All Including Blank =
COUNTROWS ( ALL ( Product[Category] ) )

Both ignore filters. ALLNOBLANKROW returns the distinct values without the blank row added for a relationship violation. ALL can include it. The two agree on clean data. The lesson: use ALLNOBLANKROW when you want an unfiltered list without the unknown member.

Example 19: Measure vs calculated table, side by side

This reuses the calculated table 'Category List' from example 09. New measures: [Categories From Measure] and [Categories From Table].

Categories From Measure =
CONCATENATEX (
    VALUES ( Product[Category] ),
    Product[Category],
    ", ",
    Product[Category], ASC
)

Categories From Table =
CONCATENATEX (
    'Category List',
    'Category List'[Category],
    ", ",
    'Category List'[Category], ASC
)

The first measure follows slicers: choose one brand and the list shrinks. The second always shows every category captured at the last refresh. 'Category List' has no relationship to Product in this model, so Product slicers do not reach it. The lesson: pick the measure when the list must respond to slicers.

Example 20: DAX query, reconcile grouped total with the grand total

DEFINE
    VAR CategorySales =
        SUMX ( VALUES ( Product[Category] ), [Total Sales] )
    VAR AllSales = [Total Sales]
EVALUATE
ROW (
    "Sales by Category", CategorySales,
    "All Sales", AllSales,
    "Difference", AllSales - CategorySales
)

The query adds up sales category by category and compares that with the overall total. On clean data the difference is zero. If some sales belong to unmatched products, a list built with DISTINCT would leave them out and the difference would be non-zero. A VALUES list can include the unknown member, so it can account for those rows. The lesson: always reconcile a unique-values list against a simple total.

Common pitfalls

  • Assuming VALUES and DISTINCT always match. They match on clean data, then diverge when an unknown member appears. Detect it by comparing both counts, as in example 15.
  • Confusing a real blank with the unknown member. A real blank is stored in the column. The unknown member comes from a relationship violation. Run the reconciliation in example 16 to tell them apart.
  • Assuming either function ignores filters. Both respect filter context. If you need an unfiltered list, that is ALL or ALLNOBLANKROW.
  • Using VALUES where a single value is needed. VALUES returns a table. When it holds one row it can be used as a scalar, but with several rows you can get an error that a table of multiple values was supplied where a single value was expected. Use SELECTEDVALUE or guard with HASONEVALUE.
  • Comparing COUNTROWS ( VALUES ( ... ) ) with DISTINCTCOUNT blindly. They may treat blanks differently. Reconcile them in the DAX query view on your own model.
  • Trusting a unique list without reconciling. Compare it against a total or row count, as in example 20.

Some behaviors may depend on your Power BI version or SSAS compatibility level, especially the table form of DISTINCT. When in doubt, test.

Best practices

  1. Choose deliberately between VALUES and DISTINCT. Decide whether the unknown member should be included. The two functions answer that question differently.
  2. Use SELECTEDVALUE for a single selected value. It replaces a hand-written IF with HASONEVALUE and is easier to read.
  3. Use DISTINCTCOUNT for a simple unique count. Reach for COUNTROWS with VALUES or DISTINCT when you need to control the blank-row behavior.
  4. Fix relationship and data-quality problems at the source. Hiding the blank row masks a real issue.
  5. Hold the unique list in a named variable. It makes the logic easier to follow.
  6. Reuse the base measures. Repeating logic invites inconsistencies.
  7. Test in the DAX query view. Compare results against a simple total or row count.
  8. Prefer a measure over a calculated table for slicer-driven lists. A calculated table is a snapshot and will not react to slicers.
  9. Document persistent calculated tables. Note their purpose, source and refresh behavior so others understand them.
  10. Format DAX consistently. Clean formatting makes review much faster.

Quick reference

SituationRecommended approach
Need the single selected valueSELECTEDVALUE
Need to test for exactly one valueHASONEVALUE
Simple unique countDISTINCTCOUNT
Count where the unknown member must be includedCOUNTROWS with VALUES
Count where the unknown member must be excludedCOUNTROWS with DISTINCT
Unfiltered list without the blank rowALLNOBLANKROW
Slicer-driven listA measure using VALUES or DISTINCT
Fixed snapshot listA calculated table (document it)

FAQ

Is DISTINCT deprecated or replaced by VALUES?

There is no basis for saying so. Both functions are documented, and they behave differently around the blank row and in the table form. Choose by behavior, not by rumor.

Why does VALUES return one more row than DISTINCT?

Usually because the model has fact rows with no matching dimension row, so VALUES includes the unknown member.

Can I use VALUES or DISTINCT in a calculated table?

Yes, as in example 09. The table is computed at refresh and stays fixed until the next refresh. It will not react to slicers.

Is VALUES faster than DISTINCT?

I do not make speed claims. Performance depends on your model and your query, so measure it in your own environment.

Conclusion

VALUES and DISTINCT look like twins, but they differ in one important way: how they treat the unknown member created by a relationship violation. Remember these takeaways:

  • Both return tables and both respect filter context.
  • VALUES can include the unknown member and underpins HASONEVALUE and SELECTEDVALUE logic.
  • DISTINCT does not add that blank row, and its table form accepts table expressions in newer releases.
  • A real blank in a column is different from the unknown member.
  • Always reconcile a unique list against a simple total.

Related reading: see my earlier articles on CALCULATE, calculated tables and columns, and explicit measures.

Want more practical Power BI, DAX and SSAS Tabular guides? Visit exceltobi.com for more tutorials and techniques.