Forum Discussion
patrick3
6 years agoHelper II
Return value based on Date / Key pair
Hi all, I've got 2 tables: Date Unique Key Value 01/01/2019 abc123 5 01/02/2019 abc123 10 01/01/2019 abc456 5 01/02/2019 abc456 10 Date Unique Key Value ...
az38
6 years agoCommunity Champion
hi patrick3
why for abc456 in table 2 returns 5, not 10 (newest in table 1 that older then abc456)?
do not hesitate to give a kudo to useful posts and mark solutions as solution
- patrick36 years agoHelper IIAh you're right of course, just a typo on my end
- az386 years agoCommunity Champion
try a measure in table2
Value = var _maxDate = CALCULATE(MAX('Table1'[Date]);FILTER(ALL(Table1);Table1[Unique Key]=SELECTEDVALUE(Table2[Unique Key]) && Table1[Date]<SELECTEDVALUE(Table2[Date]))) RETURN calculate(MAX('Table1'[Value]);FILTER(ALL(Table1);Table1[Date]=_maxDate && Table1[Unique Key]=SELECTEDVALUE(Table2[Unique Key])))do not hesitate to give a kudo to useful posts and mark solutions as solution
- patrick36 years agoHelper II
No, that doesn't seem to work - could it be because my table 1 could have more than 2 dates? I think the max is about 10, but that only keeps growing.