Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Most recent record from another table

I have two tables joined by ID. Table 1 is just a list of unique IDs and Table 2 has multiple IDs with a note and date for each. I need to add a column to Table 1 to bring in the most recent note int...
  • fhill's avatar
    fhill
    6 years ago

     

    Here you go, FINALLY!  2 Custom Columns required...

     

    Max Date = CALCULATE(MAX(Table2[Date]))    ** Make this one First, to make Part 2 below easier. **

    Column 2 = CALCULATE(LASTNONBLANK(Table2[Notes],TRUE()), FILTER( Table2, Table1[ID] = Table2[ID] && Table2[Date] = Table1[Max Date]))
     

    ** You don't have to display Max Date, it just has to be another Custom Column on the table. **

    Table 1:

    IDMax DateColumn 2
    12310/31/2019 0:00Note 3
    45611/2/2019 0:00Note1a - Dup
    55911/1/2019 0:00NEW NOTE
    78910/31/2019 0:00Note5

     

    Table 2:

    IDDateNotes
    1238/20/2019 0:00Note 1
    12310/30/2019 0:00Note 2
    12310/31/2019 0:00Note 3
    4565/1/2019 0:00Note 1
    4565/6/2019 0:00Note 2
    4565/30/2019 0:00Note 3
    4566/1/2019 0:00Note 4
    45610/31/2019 0:00Note1a
    45611/2/2019 0:00Note1a - Dup
    55911/1/2019 0:00NEW NOTE
    78910/8/2019 0:00Note 1
    78910/31/2019 0:00Note5