COLUMNSTATISTICS
A row for every column of every table: its least and greatest value, its number of distinct values and its longest text.
Group: Table manipulation. Compatible with DAX.
Syntax
COLUMNSTATISTICS ( )
It takes no parameters.
Returns
Table. A row for each column of the model's tables, giving Table Name, Column Name, Min, Max, Cardinality and Max Length.
Remarks
- Min and Max are the least and the greatest value, blanks left out. Cardinality is the number of different values, a blank counting as one. Max Length is the length of the longest text, blank for other types.
- Each table starts with a row for its hidden row-number column, whose Cardinality is the table's number of rows.
- It always describes the whole model: filters do not narrow it. Use it right after
EVALUATE; Power BI refuses it where a filter is in force, for example insideCALCULATETABLE. - Under row-level security a user's figures cover the rows they may see, and tables or columns hidden from them are left out.
- It is a tool for getting to know a model in a query, not for a report.
Examples
The columns of one table
Two holdings have no price: the Price column holds three prices and a blank, four values.
EVALUATE
SELECTCOLUMNS (
FILTER ( COLUMNSTATISTICS (), [Table Name] = "Holdings" ),
"Column", [Column Name],
"Least", [Min],
"Greatest", [Max],
"Values", [Cardinality],
"Longest text", [Max Length]
)
ORDER BY [Column]
| Column | Least | Greatest | Values | Longest text |
|---|---|---|---|---|
| Bond | Corporate 2030 | Municipal 2031 | 5 | 15 |
| Coupon | 0.0225 | 0.0475 | 5 | (blank) |
| Maturity | 2028-03-02 | 2033-03-15 | 5 | (blank) |
| Nominal | 80000000 | 300000000 | 5 | (blank) |
| Price | 92.15 | 101.3 | 4 | (blank) |
| RowNumber-2662979B-1795-4F74-8F37-6A1BA8059B61 | (blank) | (blank) | 5 | (blank) |
How many rows each table has
The row-number column's cardinality is the table's row count.
EVALUATE
SELECTCOLUMNS (
FILTER ( COLUMNSTATISTICS (), LEFT ( [Column Name], 10 ) = "RowNumber-" ),
"Table", [Table Name],
"Rows", [Cardinality]
)
ORDER BY [Table]
| Table | Rows |
|---|---|
| Accounts | 28 |
| Brewing | 23 |
| Companies | 8 |
| Countries | 176 |
| Demand | 4 |
| Distances | 240 |
| Holdings | 5 |
| Ledger | 4941 |
| Periods | 36 |
| Places | 16 |
| Plants | 3 |
| Prices | 1542 |
| Production | 12 |
| Products | 4 |
| Rates | 8 |
| Sales | 2160 |
| Suppliers | 15 |
Related functions
COUNTROWS, DISTINCTCOUNT, MIN, MAX, LEN.