Forum Discussion
Anonymous
6 years agoNot applicable
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...
- 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:
ID Max Date Column 2 123 10/31/2019 0:00 Note 3 456 11/2/2019 0:00 Note1a - Dup 559 11/1/2019 0:00 NEW NOTE 789 10/31/2019 0:00 Note5 Table 2:
ID Date Notes 123 8/20/2019 0:00 Note 1 123 10/30/2019 0:00 Note 2 123 10/31/2019 0:00 Note 3 456 5/1/2019 0:00 Note 1 456 5/6/2019 0:00 Note 2 456 5/30/2019 0:00 Note 3 456 6/1/2019 0:00 Note 4 456 10/31/2019 0:00 Note1a 456 11/2/2019 0:00 Note1a - Dup 559 11/1/2019 0:00 NEW NOTE 789 10/8/2019 0:00 Note 1 789 10/31/2019 0:00 Note5
fhill
6 years agoResident Rockstar
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:
| ID | Max Date | Column 2 |
| 123 | 10/31/2019 0:00 | Note 3 |
| 456 | 11/2/2019 0:00 | Note1a - Dup |
| 559 | 11/1/2019 0:00 | NEW NOTE |
| 789 | 10/31/2019 0:00 | Note5 |
Table 2:
| ID | Date | Notes |
| 123 | 8/20/2019 0:00 | Note 1 |
| 123 | 10/30/2019 0:00 | Note 2 |
| 123 | 10/31/2019 0:00 | Note 3 |
| 456 | 5/1/2019 0:00 | Note 1 |
| 456 | 5/6/2019 0:00 | Note 2 |
| 456 | 5/30/2019 0:00 | Note 3 |
| 456 | 6/1/2019 0:00 | Note 4 |
| 456 | 10/31/2019 0:00 | Note1a |
| 456 | 11/2/2019 0:00 | Note1a - Dup |
| 559 | 11/1/2019 0:00 | NEW NOTE |
| 789 | 10/8/2019 0:00 | Note 1 |
| 789 | 10/31/2019 0:00 | Note5 |
Anonymous
6 years agoNot applicable
Woohoo! Got it to work in my sample and actual datasets! I actually already had a max date column so this worked out perfectly. Thanks so much for all of your help on this!