Forum Discussion
Retrive Status From other table using Date range
- 3 years ago
Are the two tables linked via ID column? Are you looking for a measure or a calculated column?
- 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] )
please try
Position =
VAR CurrentDate = Table2[Attendence Date]
VAR CurrentIDTable =
CALCULATETABLE ( Table2, ALLEXCEPT ( Table2, Table2[id] ) )
VAR TableAfter =
FILTER ( CurrentIDTable, Table2[Attendence Date] > CurrentDate )
VAR NextDate =
COALESCE ( MAXX ( CurrentIDTable, Table2[Attendence Date] ), TODAY () )
VAR T1 =
FILTER (
RELATEDTABLE ( Table1 ),
Table1[Joining Date] >= CurrentDate
&& Table1[Joining Date] < NextDate
)
RETURN
MAXX ( T1, Table1[Position] )
Thank you for trying to help tamerj1 , the result is not my expetations.
I try this on PBIX file here
If using the sample case on the PBIX file, I hope the result will be like this :
| ID | Attendance Date | Position |
| 1 | 2 February 2021 | Teacher |
| 1 | 3 March 2022 | Admin |
| 2 | 2 February 2021 | Teacher |
Really need your future help.
- tamerj13 years agoCommunity Champion
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] )