Forum Discussion

Locco's avatar
Locco
Helper III
4 years ago
Solved

Count changes in a value/column

I have a set of data and I need to count the amount of times there were changes in a value.   My data is setup similar to this...   TableA DateTime Part Quantity 9/20/2021 12:00:00 am 8...
  • Greg_Deckler's avatar
    Greg_Deckler
    4 years ago

    This turned out to be context issue that was solved by using ALLSELECTED versus ALL:

    Changed Column = 
      VAR __DateTime = [DateTime]
      VAR __PreviousDateTime = MAXX(FILTER(ALLSELECTED('Table'),[DateTime]<__DateTime),[DateTime])
      VAR __PreviousPart = MAXX(FILTER(ALLSELECTED('Table'),[DateTime]=__PreviousDateTime),[Part])
    RETURN
      IF([Part]=__PreviousPart,0,1)