Fabio Manniti
Fabio Manniti

Reputation: 171

Power Bi count rows for all tables in one measure

In my power Bi I would like to count rows for all my tables and having this output:

Table Name Row count
Table1 126
Table2 985
Table3 998
... ...

As long as I have few tables I can do

NEWTABLE = UNION(
  ROW("TableName","Table1", "Rowcount",ROWSCOUNT(Table1)),
  ROW("TableName","Table2", "Rowcount",ROWSCOUNT(Table2)),
  ...
)

But this starts to be complicated when I have many tables. Is there a way I can do it? Like a loop or something? Thank you

Upvotes: 1

Views: 2028

Answers (1)

msta42a
msta42a

Reputation: 3741

If you only need a metrics then you can use DaxStudio -> ViewMetrics

where cardinality is your "rowCounts"

enter image description here

If you need something more, then you can get all table name from DMV

select * from $SYSTEM.TMSCHEMA_TABLES

populate this as another table in your model, and use M language to loop through.

here useful example:

https://community.powerbi.com/t5/Power-Query/Power-query-Counting-rows-from-all-table-in-query-editor-but-not/td-p/1198489

Upvotes: 1

Related Questions