Forum Discussion
soldous
Advocate II
5 years agoCount rows for top n categories
Hi all, I need to count rows in the table which is filtered only for top n most frequent categories. I know how to get these categories: TOPN (
5,
VALUES ( Table[Category L...
- 5 years ago
Hi, soldous , a table itself can be used as filter in CALCULATE. You may want to try a measure in this pattern,
Measure = VAR __topn = TOPN ( 5, VALUES ( Table[Category Level 1] ), RANKX ( ALL ( Table[Category Level 1] ), COUNTROWS ( Table ),, ASC ) ) RETURN CALCULATE ( COUNTROWS ( Table ), __topn )It's a general idea; you're supposed to base the measure on specific context of your data model.
CNENFRNL
Community Champion
5 years agoHi, soldous , a table itself can be used as filter in CALCULATE. You may want to try a measure in this pattern,
Measure =
VAR __topn =
TOPN (
5,
VALUES ( Table[Category Level 1] ),
RANKX ( ALL ( Table[Category Level 1] ), COUNTROWS ( Table ),, ASC )
)
RETURN
CALCULATE ( COUNTROWS ( Table ), __topn )It's a general idea; you're supposed to base the measure on specific context of your data model.