Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Calculate earliest date/time after change

I have a data set with regular intervals of time stamped (ts) information.

 

I want to caluclate the earliest ts of a False state that occurs after a True. (Highlighted below)

 

 

To achieve this my current thinking is:
Figure out earliest False state ts from a filtered range of ts that's greater than last True ts

 

I run into issues with DATESBETWEEN complaining of duplicate values in the date field. I need minute graularity in my results as the state can change multiple times with a single date.

 

Any help much appreciated.

  • Try this:

     

    Measure 12 = 
    VAR __max = MAXX(FILTER(Table11,[State]=TRUE()),[ts])
    VAR __min = MINX(FILTER(Table11,[State]=FALSE() && [ts]>__max),[ts])
    RETURN __min

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Try this:

     

    Measure 12 = 
    VAR __max = MAXX(FILTER(Table11,[State]=TRUE()),[ts])
    VAR __min = MINX(FILTER(Table11,[State]=FALSE() && [ts]>__max),[ts])
    RETURN __min
    • Anonymous's avatar
      Anonymous
      Not applicable

      That works a charm! Thanks