Forum Discussion
ReutAtias12
3 years agoFrequent Visitor
count with condition
Hi All, this is my data sample: Account id attackid attack date module assessName status 1 01 1/1/22 aa xx failed 1 02 2/1/22 aa yy failed 1 03 2/1/22 cc xx failed...
- 3 years ago
Hi, ReutAtias12
Of course.
Measure:
Measure 1 = CALCULATE ( COUNT ( 'Table'[Account id] ), FILTER (ALL('Table'), [assessName] = SELECTEDVALUE( 'Table'[assessName] ) && [module] = SELECTEDVALUE( 'Table'[module] ) && [status] = "failed" && [attackid] <= SELECTEDVALUE ( 'Table'[attackid] ) ) )Measure 2 = VAR _Previous = MAXX ( FILTER ( ALL('Table'), [attackid] < SELECTEDVALUE( 'Table'[attackid] ) && [module] = SELECTEDVALUE('Table'[module] ) && [assessName] = SELECTEDVALUE( 'Table'[assessName] ) ), [attackid] ) RETURN IF ( [Measure 1] = 2, _Previous, BLANK () )Measure 3 = IF(SUM('Table'[attackid])-[Measure 2]=1&&[Measure 2]<>BLANK(),1,BLANK())Count = CALCULATE(COUNT('Table'[Account id]),FILTER(ALL('Table'),[Measure 3]=1))Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ReutAtias12
3 years agoFrequent Visitor
can it be done only with maesure and not with calculated column ?
v-zhangti
Community Support
3 years agoHi, ReutAtias12
Of course.
Measure:
Measure 1 =
CALCULATE (
COUNT ( 'Table'[Account id] ),
FILTER (ALL('Table'),
[assessName] = SELECTEDVALUE( 'Table'[assessName] )
&& [module] = SELECTEDVALUE( 'Table'[module] )
&& [status] = "failed"
&& [attackid] <= SELECTEDVALUE ( 'Table'[attackid] )
)
)Measure 2 =
VAR _Previous =
MAXX (
FILTER (
ALL('Table'),
[attackid] < SELECTEDVALUE( 'Table'[attackid] )
&& [module] = SELECTEDVALUE('Table'[module] )
&& [assessName] = SELECTEDVALUE( 'Table'[assessName] )
),
[attackid]
)
RETURN
IF ( [Measure 1] = 2, _Previous, BLANK () )Measure 3 = IF(SUM('Table'[attackid])-[Measure 2]=1&&[Measure 2]<>BLANK(),1,BLANK())Count = CALCULATE(COUNT('Table'[Account id]),FILTER(ALL('Table'),[Measure 3]=1))
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- ReutAtias123 years agoFrequent Visitor
first of all thank you!!
one more thing,
if the attack id and the account id are type text (can include text and number as an id)
how eill that change the maesures?