Greg_Deckler's avatar
Greg_Deckler
Community Champion
5 years ago

Cycles Count

OK, this one counts cycles as devices move through different states. In this case, each time a device hits the "1" state, the cycle count increases per device. It is computationally intensive.

 

Cycles Count = 
    VAR __BaseTable = ALL('Table')
    VAR __device = MAX([device])
    VAR __Index = MAX([Index])
    VAR __Table = 
        ADDCOLUMNS(
            ADDCOLUMNS(
                ADDCOLUMNS(
                    FILTER(ALL('Table'),[device]=__device && [index]<=__Index),
                    "__Previous",MAXX(FILTER(__BaseTable,[device]=EARLIER([device]) && [Index]<EARLIER([Index])),[Index])
                ),
                "__PreviousState",MAXX(FILTER(__BaseTable,[Index]=[__Previous]),[State])
            ),
            "__CycleChange",IF(([State]=1 && [__PreviousState]<>1),1,0)
        )
RETURN
   SUMX(__Table,[__CycleChange])

 

 

 

No RepliesBe the first to reply