简体   繁体   中英

In Power Bi how to create a measure giving Number of Rows in a Table Visual

I know similarly named topics exist but I spent hours looking for the answer to something which i feel must be easy to do.

I have a table Visual in Power Bi and need to get a row count which would adjust as users set filters and use slicers. The columns in the table don't have one level of hierarchy (otherwise a measure with DISTINCTCOUNT would do the trick), see an image of my table - I need to count rows in this table (21).

我的表视觉

I couldn't find any way to directly refer to the Table Visual in DAX so simple COUNTROWS() wasn't useful. I tried to create a measure using various DAX expressions i found, eg recreate the table in DAX using CALCULATETABLE and have it use active filters, i failed there...

I also created an index variable on the physical/dataset table and tried to add it to the visual table and summarize it in some way (the column "Counter" in the table) - it didn't work, didn't give me the number of rows in the visual table but gave the number of rows in the physical/database table.

Please could you help me how to do this...

You won't really be able to access the table visual in the way you're thinking, but as long as you know how it comes together, that should be just as good.

CountSummaryRows = 
CALCULATE(
    COUNTROWS(SUMMARIZE(Table1, Table1[A], Table1[B], Table1[C], Table1[D])), 
    ALL(Table1)
    )

This measure will aggregate to the level of your A,B,C,D columns, then count the total. ALL(Table1) just ensures you get the grand total, so every row should show as 21, but at least you'll have a handle on that summary table count.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM