DISTINCTCOUNT BLANK: How to Test Missing Values in DAX
Test DISTINCTCOUNT BLANK behavior in Power BI with DAX examples. Compare missing values, empty filters and unknown members before fixing totals.
Author: jackey.ye | Updated: 2026-11-27
DISTINCTCOUNT counts BLANK as one distinct value; DISTINCTCOUNTNOBLANK does not, so the two split by one whenever a column holds a BLANK beside real values. This guide separates four conditions that look like missing data — stored BLANK, an empty filtered table, an empty string, and a relationship blank row — using a reproducible DAX fixture with hand-derived outputs.
Does DISTINCTCOUNT count BLANK as a value, and how does DISTINCTCOUNTNOBLANK differ?
Yes. DISTINCTCOUNT counts the BLANK value as one distinct value, and DISTINCTCOUNTNOBLANK does not count it. Both accept a single column argument of any data type, and both return the number of distinct values in that column.
The practical consequence is narrow and predictable: whenever the evaluated column contains at least one BLANK and at least one non-blank value, the two measures differ by exactly one. If the column has no BLANK, they return identical numbers — which is why a model can pass months of spot checks and then diverge the first time an unmatched key or a null load appears.
One documented edge case breaks the "difference of one" rule. DISTINCTCOUNT returns BLANK, not zero, when it finds no rows to count. So a filter context that yields an empty table produces a blank cell in the visual, while a context containing a single blank value produces 1. Those are different states, and a report that renders both as an empty cell hides the distinction. Microsoft's own reference example shows the same divergence on a date column: DISTINCTCOUNTNOBLANK returns 2 and DISTINCTCOUNT returns 3, because one BLANK is present.
Treat the pair as two definitions of the same measure, not as a fix and a bug. Decide whether unknown or missing members belong in the business count, then apply that decision consistently to the measure, the visual and the reconciliation note.
How do I tell a stored BLANK apart from an empty filtered table, an empty string and a relationship blank row?
Read the four conditions by what physically exists in the model, because each one produces a different result and needs a different detection method. A stored BLANK is a value sitting in a column; an empty filtered table is zero rows; an empty string is a text value that may or may not equal BLANK depending on the operation; a relationship blank row is a member the engine generates, not one your source data contains.
Hand-derived expected outputs for the four-row DATATABLE fixture (Code: A, B, C, D; Amount: 10, 20, BLANK, 30). Values are unexecuted and must be confirmed in your own model. The empty-filter and unknown-member cases are not represented here because a DATATABLE has no relationships and always returns rows.
Condition | What exists in the model | DISTINCTCOUNT result | DISTINCTCOUNTNOBLANK result | How to detect it |
|---|---|---|---|---|
Physical BLANK stored in a column | One row whose column value is BLANK | Counts it as one distinct value (e.g. 4) | Excludes it (e.g. 3) | Compare the two measures; count rows where ISBLANK is TRUE |
Filter returns zero rows | No rows in the filter context | Returns BLANK, not 0 | Returns BLANK, not 0 | Wrap in COUNTROWS over the same filter; test with ISBLANK |
Empty string stored as text | A text value that may normalize toward BLANK, depending on the operation and the source | Depends on the operation — may count it or fold it into BLANK | Depends on the operation — not guaranteed to differ from DISTINCTCOUNT | Compare a row count against each distinct count, and test with ==; verify the specific column |
Relationship blank row (unknown member) | A virtual row added to the "one" side by table expansion, blank in every column including the key | Depends on the column's storage and the count expression used | Depends on the same factors — DISTINCTCOUNTNOBLANK does not automatically exclude it | Run COUNTROWS(VALUES(Dim[Key])) and a distinct count over the key side by side while the unmatched filter is active |
Two rows in that table deserve emphasis. First, the empty-string row: Microsoft's BLANK reference states that blanks are not equivalent to nulls, and that blanks and empty strings are not always equivalent, though some operations may treat them as such. So "" is not guaranteed to be a distinct text value — the column's storage or the operation applied can normalize it toward BLANK. Don't assume the outcome for a text column; verify it in your own model, because it depends on both the operation and the data type involved.
Second, the unknown-member row: switching to DISTINCTCOUNTNOBLANK does not rescue you there. The generated row is blank in every column, key included, so a distinct count over the dimension key does not automatically exclude it. Whether each expression counts it depends on the column's storage behavior, which is why the side-by-side comparison — not the function name — is the diagnostic.
Why does an unmatched fact key create an extra member in a dimension, and what does it do to my distinct count?
Because regular one-to-many relationships expand tables with LEFT OUTER JOIN semantics. When a value on the "many" side has no matching value on the "one" side, Microsoft's relationship evaluation documentation states that a blank virtual row is added to the "one" side table. Those blank virtual rows are unknown members, and Microsoft describes them as referential integrity violations that ideally should not exist.
Here is where the "difference of one" intuition fails, so treat this as a cautious diagnostic rather than a rule. The generated row carries a blank in every column, including the key. A measure such as COUNTROWS ( VALUES ( Dim[Key] ) ) and a distinct count over that same key can therefore disagree, because a distinct count over a column does not simply tally rows — its physical-storage behavior decides whether a blank row is counted at all. The model's storage mode (imported versus DirectQuery) and the engine that evaluates the query both change what you observe. So don't assert that DISTINCTCOUNT always adds one and DISTINCTCOUNTNOBLANK always includes it; instead, run COUNTROWS ( VALUES ( Dim[Key] ) ) beside a DISTINCTCOUNT ( Dim[Key] ), filter to the region that holds the unmatched key, and read what each expression actually returns in your model. A matrix row or column that no source record explains is the signal that the counts diverge.
Cardinality matters here. The blank virtual row is added only for regular relationships. Limited relationships — including many-to-many relationships achieved with an intermediary table and at least one bi-directional relationship — never undergo table expansion, and Microsoft documents that their joins use INNER JOIN semantics, so no blank row is added to compensate for referential integrity violations. The same unmatched fact key can therefore appear as a member in one model and vanish in another. Check the relationship type before concluding the data is clean.
For how distinct counts behave across matrix rows and totals — a separate problem from missing values — see Power BI DISTINCTCOUNT totals: why matrix totals differ from row sums. This article stays on missing-value behavior and does not repeat that totals logic.
How do I build a small reproducible DATATABLE test with expected outputs I can check by hand?
Declare a tiny table with a known mix of BLANK, empty string and real values, evaluate both functions against it, and compare the results to counts you derived on paper. If the numbers match, the semantics are confirmed for that data type; if they do not, your assumption about how the engine stores the value is wrong, and you have found that out on four rows instead of a production model.
Prerequisites. A Power BI Desktop model or an SSAS tabular model that accepts DAX queries, plus DAX query view in Power BI Desktop or DAX Studio. The dialect is DAX. The fixture uses DATATABLE, whose documentation notes that a missing value in the row array is treated identically to BLANK() — which is exactly why the fixture can express a stored blank as an omitted cell.
Check your outputs against these hand-derived expectations as you work through the steps:
Measure | Hand-derived expectation | Reasoning |
|---|---|---|
DistinctCodes | 4 | Four distinct non-blank text values |
DistinctCodesNoBlank | 4 | No BLANK present, so no difference |
DistinctAmounts | 4 | 10, 20, BLANK, 30 — BLANK counted once |
DistinctAmountsNoBlank | 3 | 10, 20, 30 — BLANK excluded |
Create the fixture as a calculated table. In Power BI Desktop, use Modeling → New table and paste this definition. A calculated table persists in the model, unlike an
EVALUATE DATATABLE(...)query, which returns rows for that query only and stores nothing.Fixture = DATATABLE ( "Code", STRING, "Amount", INTEGER, { { "A", 10 }, { "B", 20 }, { "C", BLANK() }, { "D", 30 } } )Checkpoint: the
Fixturetable appears in the model with four rows, and theAmountcell for codeCis empty.Count distinct codes and amounts. In DAX query view or DAX Studio, run a separate
EVALUATEagainst the saved table; the fixture is already materialized, so the query does not redefine it.EVALUATE ROW ( "DistinctCodes", DISTINCTCOUNT ( Fixture[Code] ), "DistinctCodesNoBlank", DISTINCTCOUNTNOBLANK ( Fixture[Code] ), "DistinctAmounts", DISTINCTCOUNT ( Fixture[Amount] ), "DistinctAmountsNoBlank", DISTINCTCOUNTNOBLANK ( Fixture[Amount] ) )Compare the output with the table above. The
Codecolumn holds four non-blank text values, so both functions return 4. TheAmountcolumn holds 10, 20, BLANK and 30, so DISTINCTCOUNT returns 4 and DISTINCTCOUNTNOBLANK returns 3. These outputs are hand-derived and unexecuted here; confirm them in your own environment before relying on them.Optional — add an empty-string column and re-run. To test text handling, extend the calculated table with a
Labeltext column that stores""for one row, then re-run theEVALUATEagainstFixture[Label].Fixture = DATATABLE ( "Code", STRING, "Amount", INTEGER, "Label", STRING, { { "A", 10, "x" }, { "B", 20, "y" }, { "C", BLANK(), BLANK() }, { "D", 30, "" } } )Whether
""counts as a distinct value or normalizes toward BLANK depends on the operation and the column's storage, so compare the two counts overFixture[Label]rather than assuming either outcome.Apply an empty filter inside the row expression. To test the zero-row case, place the filter on
ROWwithCALCULATETABLE, so both distinct-count measures receive the same empty filter context. WrapCOUNTROWSinCOALESCEif you need a numeric zero for display, becauseCOUNTROWSover an empty table returns BLANK rather than 0.EVALUATE CALCULATETABLE ( ROW ( "RowsInContext", COALESCE ( COUNTROWS ( Fixture ), 0 ), "DistinctInContext", DISTINCTCOUNT ( Fixture[Amount] ), "DistinctNoBlankInContext", DISTINCTCOUNTNOBLANK ( Fixture[Amount] ) ), FILTER ( Fixture, Fixture[Amount] > 1000 ) )Checkpoint:
RowsInContextis 0 only because of theCOALESCE;COUNTROWSalone returns BLANK. Both distinct counts return BLANK rather than 0 — the documented behavior when the function finds no rows to count. If your report renders this as an empty cell, that is correct, not a broken measure.Record the results. Store the fixture, the query and the expected outputs alongside the semantic model so the next change to the measure can be re-tested against the same baseline. The AI SQL query audit trails guide covers the equivalent correlation discipline for warehouse-side queries when you need to trace which run produced which number.
What are the limits of these tests before I trust them in my own model?
The fixtures prove DAX semantics in isolation. They do not prove your model's data quality, its relationship configuration, or that the same behavior survives a storage-mode change. Treat a passing fixture as a confirmed definition, not as a clean bill of health for the report.
The most important gap is relationships. A DATATABLE fixture has no relationships, so it cannot reproduce the unknown-member case at all. That case must be tested against an actual regular relationship in your model — ideally by inserting a fact row with a key that does not exist in the dimension, then comparing COUNTROWS ( VALUES ( Dim[Key] ) ) with a distinct count over the same key while the filter that holds the unmatched key is active. Watch how each expression reacts rather than expecting a fixed increment. Then repeat the check on any limited relationship in the same model, where Microsoft documents that no blank row is added.
Storage mode is the second limit. Both DISTINCTCOUNT and DISTINCTCOUNTNOBLANK are documented as not supported for use in DirectQuery mode when used in calculated columns or row-level security rules. That documented restriction applies to those two uses, not to a measure evaluated outside them; confirm the storage mode and which case your model relies on before you commit to the design.
The third limit is value equivalence. Microsoft's BLANK documentation is explicit that blanks and empty strings are not always equivalent, and that some operations may treat them as such. That means an empty-string test result is only valid for the data type and the operation you actually tested. Text columns arriving from different source systems can behave differently, and collation or locale settings can affect how text values compare. Test the specific column, not the general category.
Finally, every output in this article is hand-derived and unexecuted until you run it. That is deliberate — it gives you a baseline to check against rather than a number to trust. Teams that keep such baselines under version control alongside the semantic model, as part of a governed validation process for the model itself, tend to catch these divergences before a stakeholder does.
FAQ
Short answers to the questions this behavior raises most often.
Does DISTINCTCOUNT count BLANK as a value?
Yes. DISTINCTCOUNT counts BLANK as one distinct value, and DISTINCTCOUNTNOBLANK excludes it, so the two differ by exactly one whenever the column contains at least one BLANK and at least one non-blank value.
How do I distinguish a stored BLANK from an empty filtered table, an empty string, and a relationship blank row?
A stored BLANK is a value in a column and is counted by DISTINCTCOUNT; an empty filtered table returns no rows, so DISTINCTCOUNT returns BLANK rather than 0; an empty string may normalize toward BLANK depending on the operation, so test the specific column rather than assuming it counts as a distinct text value; a relationship blank row is an unknown member generated by LEFT OUTER JOIN table expansion, blank in every column including the key.
Why does an unmatched fact key add an extra member to my distinct count?
Regular one-to-many relationships expand tables with LEFT OUTER JOIN semantics, so an unmatched "many"-side key produces a blank virtual row on the "one" side, and that row is blank in every column including the key. Whether a given count expression picks it up depends on the column's physical-storage behavior, so compare COUNTROWS(VALUES(Dim[Key])) with a distinct count over the key instead of assuming a fixed increment.
How do I build a reproducible DATATABLE test with expected outputs?
Declare a DATATABLE with known BLANK, empty-string and real values, evaluate DISTINCTCOUNT and DISTINCTCOUNTNOBLANK over the same columns, and compare the results to hand-counted expectations. The outputs are unexecuted until you run them in your own environment.
What are the limits of these tests before I trust them in my own model?
The fixtures prove DAX semantics, not your model's relationships or data quality. Test unknown members against a real relationship, and account for the DirectQuery restriction on calculated columns and RLS rules and for the operation-dependent equivalence of empty strings and BLANK.