Forum Discussion

TaufikMaggangka's avatar
3 years ago
Solved

Retrive Status From other table using Date range

Hi Everyone, Really need help from expert to retrive status from other table using date parameter and ID. Here my case : Table 1 Id Joining Date Position 1 1 January 2021 Teacher 1 ...
  • tamerj1's avatar
    3 years ago

    Hi TaufikMaggangka 

    Are the two tables linked via ID column? Are you looking for a measure or a calculated column?

  • tamerj1's avatar
    tamerj1
    3 years ago

    TaufikMaggangka 
    Yes you are right, I did it the other way around which was wrong.

    Please refer to attached sample file with the solution

     

    Position = 
    VAR T1 = RELATEDTABLE ( 'Table 1' )
    VAR T2 =
        FILTER (
            T1,
            VAR CurrentAttendanceDate = 'Table 2'[Attendance Date]
            VAR CurrentJoiningDate = 'Table 1'[Joining Date]
            VAR T3 = FILTER ( T1, 'Table 1'[Joining Date] > CurrentJoiningDate )
            VAR NextJoiningDate = COALESCE ( MAXX ( T3, 'Table 1'[Joining Date] ), TODAY ( ) )
            RETURN
            CurrentAttendanceDate >= CurrentJoiningDate
                && CurrentAttendanceDate < NextJoiningDate
        )
    RETURN
        MAXX ( T2, 'Table 1'[Position] )