Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Count Rows per Group with Filter Responsiveness

Hi folks, I'm trying to create a measure that will respond to filters to give me the number of rows in each group (defined by the value of two columns). Example:

IDClassificationDaysCount
ID1Historical72
ID1Historical142
ID1Historical211
ID2Historical72
ID2Historical142
ID3Current73
ID3Current141
ID3Current211
ID4Current73
ID5Current73

 

I'm currently using the expression Count = CALCULATE(COUNT([ID]), ALLEXCEPT(TableName, [Classification], [Days])) but this isn't responsive to filters. So, for instance, if I filter by another column and wind up with the following data, the Count column doesn't change:

IDClassificationDaysCount (with current formula - same as above)VALUE I NEED
ID1Historical721
ID1Historical1421
ID1Historical2111
ID4Current731

 

Does anyone have suggestions for how to get the column values I need?

  • Hi Anonymous 

    try a measure

    Count = CALCULATE(COUNTROWS(TableName),
    FILTER(ALLSELECTED(TableName),
    TableName[Classification]=SELECTEDVALUE(TableName[Classification]) && TableName[Days]=SELECTEDVALUE(TableName[Days])))

2 Replies

  • VasTg's avatar
    VasTg
    Memorable Member

    Anonymous 

     

    Replace COUNT with DISTINCTCOUNT

     

    If it helps, mark it as a solution
    Kudos are nice too

  • az38's avatar
    az38
    Community Champion

    Hi Anonymous 

    try a measure

    Count = CALCULATE(COUNTROWS(TableName),
    FILTER(ALLSELECTED(TableName),
    TableName[Classification]=SELECTEDVALUE(TableName[Classification]) && TableName[Days]=SELECTEDVALUE(TableName[Days])))