COLUMNSTATISTICS DAX Function (Information)
Provides statistics regarding every column in every table in the model.
Syntax
This expression has no parameters.
Return values
One row for each column visible in the model to the current user, with the following data: Table Name, Column Name, Min, Max, Cardinality, Max Length.
Remarks
In the following remarks, “column” relates to the result of the function and “attribute” to a column in the data model.
The COLUMNSTATISTICS function returns the attributes and values visible to the user considering the security roles. Different users can get different results querying the same model because of different security profiles.
The Cardinality column provides the number of unique values for each attribute in the data model. For rows where Column Name begins with “RowNumber”, the value of Cardinality corresponds to the number of rows in the table. When supported in DirectQuery, the value of Cardinality is approximate, whereas it is the exact number for tables imported in memory. If not supported, then the Cardinality is blank.
The Min and Max columns show the minimum and maximum values visible in the attribute.
The Max Length column shows the maximum length of strings visible in the attribute.
When used with a DirectQuery data source over SQL Server, it is compatible only with SQL Server 2019 or later version, because internally it uses APPROX_COUNT_DISTINCT to compute the Cardinality value.
COLUMNSTATISTICS returns an error when it runs in a filter context. For example, it returns an error inside CALCULATETABLE with a filter argument, or in a measure that SUMMARIZECOLUMNS evaluates for each group. Use COLUMNSTATISTICS directly in EVALUATE.
The result includes hidden columns, calculated columns, and the RowNumber column of each table. The result also includes the columns that the query defines with DEFINE COLUMN, but not the columns of the tables that the query defines with DEFINE TABLE. If a column defined with DEFINE COLUMN returns an error, the whole query returns an error.
Columns in an error state in the model are not in the result. For binary columns, Min and Max are BLANK.
Examples
EVALUATE COLUMNSTATISTICS()
| Table Name | Column Name | Min | Max | Cardinality | Max Length |
|---|---|---|---|---|---|
| Product | RowNumber-2662979B-1795-4F74-8F37-6A1BA8059B61 | (Blank) | (Blank) | 2,517 | (Blank) |
| Product | ProductKey | 1 | 2517 | 2,517 | (Blank) |
| Product | Product Code | 0101001 | 0808078 | 2,517 | 7 |
| … | … | . | . | . | . |
| Date | RowNumber-2662979B-1795-4F74-8F37-6A1BA8059B61 | (Blank) | (Blank) | 2,556 | (Blank) |
| Date | Date | 2005-01-01 | 2011-12-31 | 2,556 | (Blank) |
| Date | DateKey | 20050101 | 20111231 | 2,556 | (Blank) |
| Date | Calendar Year Number | 2005 | 2011 | 7 | (Blank) |
| … | … | . | . | . | . |
| Date | Holiday Name | 4th of July | Thanksgiving Day | 8 | 27 |
| Date | 445 Week Start | 2004-12-26 | 2011-12-25 | 366 | (Blank) |
| Date | 445 Week End | 2005-01-01 | 2011-12-31 | 366 | (Blank) |
| Date | 445 Year Number | 2004 | 2011 | 8 | (Blank) |
| Date | 445 Year | WY 2004 | WY 2011 | 8 | 7 |
| Date | 445 Week Number | 1 | 53 | 53 | (Blank) |
| Date | 445 Week | W01 | W53 | 53 | 3 |
| Date | 445 Year Week Number | 200452 | 201152 | 366 | (Blank) |
| Date | 445 Year Week | W01-2005 | W53-2008 | 366 | 8 |
| Date | 445 Quarter Number | 1 | 4 | 4 | (Blank) |
| Date | 445 Quarter | Q1 | Q4 | 4 | 2 |
| Date | 445 Year Quarter Number | 20044 | 20114 | 29 | (Blank) |
| Date | 445 Year Quarter | Q1-2005 | Q4-2011 | 29 | 7 |
| Date | 445 Period Number | 1 | 12 | 12 | (Blank) |
| Date | 445 Period | P01 | P12 | 12 | 3 |
| Date | 445 Year Period Number | 200412 | 201112 | 85 | (Blank) |
| Date | 445 Year Period | P01-2005 | P12-2011 | 85 | 8 |
| … | … | . | . | . | . |
| ColorGroups | RowNumber-2662979B-1795-4F74-8F37-6A1BA8059B61 | (Blank) | (Blank) | 4 | (Blank) |
| ColorGroups | Group | Trend 2009 | Trend 2010 | 2 | 10 |
| ColorGroups | Color | Blue | Yellow | 3 | 6 |
-- COLUMNSTATISTICS also returns the columns defined in the query
-- with DEFINE COLUMN (Customer[Location]).
-- It does not return the columns of a table defined in the query
-- with DEFINE TABLE (BlueProducts).
DEFINE
TABLE BlueProducts =
FILTER ( 'Product', 'Product'[Color] = "Blue" )
COLUMN Customer[Location] = Customer[City] & ", " & Customer[CountryRegion]
EVALUATE
FILTER (
COLUMNSTATISTICS (),
[Table Name] IN { "BlueProducts", "Customer" }
&& [Column Name] IN { "ProductKey", "City", "CountryRegion", "Location" }
)
| Table Name | Column Name | Min | Max | Cardinality | Max Length |
|---|---|---|---|---|---|
| Customer | City | Albany | York | 473 | 21 |
| Customer | CountryRegion | Armenia | United States | 29 | 15 |
| Customer | Location | Albany, United States | York, United Kingdom | 474 | 35 |
Last update: Nov 9, 2026 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber
Microsoft documentation: https://learn.microsoft.com/en-us/dax/columnstatistics-function-dax