Forum Discussion
SimDam
Helper I
3 years agoCount group by with condition
Hi, Considering the below table Order Period Item Test 100 7/1/2022 1 0 100 7/1/2022 2 0 100 7/1/2022 3 1 100 8/1/2022 1 0 100 8/1/2022 2 0 ...
FreemanZ
Super User
3 years agohi SimDam
try to write the measure like this:
TestCount =
VAR _table =
ADDCOLUMNS(
VALUES(TableName[Period]),
"Test",
CALCULATE(MAX(TableName[Test]))
)
RETURN
COUNTROWS(FILTER(_table, [Test]=1))
it worked like this:
- FreemanZ3 years ago
Super User
you may also write like this:
TestCount2 = VAR _table = CALCULATETABLE( TableName, TableName[Test]=1 ) VAR _table1 = SUMMARIZE( _table, TableName[Period] ) RETURN COUNTROWS(_table1)or
TestCount3 = VAR _table = FILTER( TableName, TableName[Test]=1 ) VAR _table1 = SUMMARIZE( _table, TableName[Period] ) RETURN COUNTROWS(_table1) - SimDam3 years ago
Helper I
This is already working so I will go for it.
Thanks!