Forum Discussion

davidgaribaldi's avatar
6 years ago
Solved

Counting consecutive values

Hi I'm trying to count consecutive rows that match.   I have an ID column, a date column, and then a value column. I'm sorting by the ID then the date and I'd like for it to tell me the length of t...
  • dax's avatar
    dax
    6 years ago

    Hi davidgaribaldi,

    You could try below measure to see whether it work or not

    Measure 3 =
    VAR temp =
        CALCULATE (
            COUNT ( t5[ID] ),
            FILTER ( ALLEXCEPT ( t5, t5[ID], t5[ Value] ), t5[ Date] <= MIN ( t5[ Date] ) )
        )
    RETURN
        IF (
            CALCULATE ( COUNT ( t5[ Value] ), ALLEXCEPT ( t5, t5[ID], t5[ Value] ) ) > 1
                && temp = 1,
            0,
            temp
        )
    

    Best Regards,
    Zoe Zhi

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.