Forum Discussion

numersoz's avatar
numersoz
Helper III
6 years ago
Solved

Flag Consecutive Values

Hi,   I have hourly timestamp sensor data. I would like to flag when a certain sensor value is below a certain threshold at least four consecutive hours within a day. For example,  Day 1 ther...
  • v-deddai1-msft's avatar
    v-deddai1-msft
    6 years ago

    Hi numersoz ,

     

    Create a date column for your table:

     

    Date = 'Table'[Time Stamp].[Date]

     

    Then you can use the following measure :

     

    Measure = 
    VAR t =
        SUMMARIZE (
            'Table',
            'Table'[Time Stamp],'Table'[Date],'Table'[Value],
            "aa", IF (
                0
                    IN CALCULATETABLE (
                        VALUES ( 'Table'[Value] ),
                        FILTER (
                    'Table',
                            'Table'[Time Stamp]
                                >= EARLIER ( 'Table'[Time Stamp] ) - 1 / 8
                                && 'Table'[Time Stamp] <= EARLIER('Table'[Time Stamp] )
                                && 'Table'[Date] = EARLIER('Table'[Date])
                        )
                    ),
                1,
                0
            )
        )
    RETURN
        IF ( COUNTX ( FILTER ( t, [aa] = 0 &&COUNTROWS(t)>=4),[aa]) > 0, "flagged", "unflagged" )

     

     

     

     

     

    Please refer to the pbix file:  https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ERoNh4-nNQpEufq-8Nl3glIBjc0tCc3J6tF3UMOUVpSkUQ?e=otD0UZ

     

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

     

    Best Regards,

    Dedmon Dai