Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Retrieving the date when a value changes

Hello,    I have 2 tables :  History (weekly imported) Name  Value DATE  Name 1  TRUE 26/01/2025 Name 2 TRUE 26/01/2025 Name 3 TRUE 26/01/2025 Name 4 FALSE 26/01/2025 ...
  • Irwan's avatar
    1 year ago

    hello Anonymous 

     

    please check if this accomodate your need (i assumed you want to do this with calculated column).

    1. create a calculated column in 'History' table with following DAX.

    Value Change Date = 
    var _PreviousDate =
    MAXX(
        FILTER(
            'History',
            'History'[DATE ]<EARLIER('History'[DATE ])&&
            'History'[Name ]=EARLIER('History'[Name ])&&
            'History'[Value]<>EARLIER('History'[Value])
        ),
        'History'[DATE ]
    )
    var _LastWeek =
    IF(
        _PreviousDate>'History'[DATE ]-8,
        _PreviousDate
    )
    var _TrueValue =
    IF(
      'History'[Value]="True",
        _LastWeek
    )
    Return
    IF(
        not ISBLANK(_TrueValue),
        'History'[DATE ]
    )
    2. create a calculated column in 'Current' table with following DAX
    Date Changed =
    MAXX(
        FILTER(
            'History',
            'Current'[Name ]='History'[Name ]
        ),
        'History'[Value Change Date]
    )

     

    Hope this will help.
    Thank you.