Forum Discussion
xjsuarexcx
3 years agoRegular Visitor
counting consecutive identical values - calculated column
Dear ones, I need your support, thank you very much! I want to list (in the "Consecutive Imbalance" column) consecutive records that have a value equal to 1 (from the "Imbalance" column)...
- 3 years ago
Hi xjsuarexcx ,
If you need a calculated column, here's my solution.
Create two calculated columns.
Flag = MAXX ( FILTER ( 'Query1', 'Query1'[Timestamp] <= EARLIER ( 'Query1'[Timestamp] ) && 'Query1'[Desbalance] = 0 ), 'Query1'[Timestamp] )Consecutive Imbalance = IF ( 'Query1'[Desbalance] = 1, RANKX ( FILTER ( 'Query1', 'Query1'[Desbalance] = 1 && 'Query1'[Flag] = EARLIER ( 'Query1'[Flag] ) ), 'Query1'[Timestamp], , ASC ) )Get the correct result.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yanjiang-msft
3 years agoCommunity Support
Hi xjsuarexcx ,
If you need a calculated column, here's my solution.
Create two calculated columns.
Flag =
MAXX (
FILTER (
'Query1',
'Query1'[Timestamp] <= EARLIER ( 'Query1'[Timestamp] )
&& 'Query1'[Desbalance] = 0
),
'Query1'[Timestamp]
)
Consecutive Imbalance =
IF (
'Query1'[Desbalance] = 1,
RANKX (
FILTER (
'Query1',
'Query1'[Desbalance] = 1
&& 'Query1'[Flag] = EARLIER ( 'Query1'[Flag] )
),
'Query1'[Timestamp],
,
ASC
)
)
Get the correct result.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.