Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dax consecutive Count by months

Hello all, i'm sorry if i posted this in a wrong category (i'm new in this community) I would like to ask for a help. I'm trying to count consecutive months. The logic is:  if the Latency Valu...
  • v-kkf-msft's avatar
    4 years ago

    Hi Anonymous ,

     

    Please create a date table and the relationship.

     

     

    Then create these measures:

     

    Measure = 
    IF ( SUM ( 'Table'[Latency Value] ) > SUM ( 'Table'[Target value] ), 1, 0 )
    Measure2 = 
    VAR tab =
        SUMMARIZE ( ALLSELECTED ( 'Date' ), 'Date'[Year_Month], "M", [Measure] )
    VAR mindate =
        CALCULATE (
            MAX ( 'Date'[Year_Month] ),
            ALLSELECTED ( 'Date' ),
            FILTER ( tab, 'Date'[Year_Month] < MAX ( 'Date'[Year_Month] ) && [M] = 0 )
        )
    RETURN
        IF (
            [Measure] = 1,
            SUMX (
                FILTER (
                    tab,
                    'Date'[Year_Month] <= MAX ( 'Date'[Year_Month] )
                        && 'Date'[Year_Month] > mindate
                ),
                [M]
            ) - 1
        )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.