Forum Discussion
LOOKUPVALUE troubles
I have two tables: Table1 has multiple lines referencing the same ID with teammate names on different dates.
On Table2, I want to bring over the teammate name from the most recent date by the ID. Creating a new column on Table2 with LOOKUPVALUE throws an error because there are multiple entries for the same ID.
Created a measure:
MuppetyMe you can use the following expression to add a new column in the table2, assuming table 1 and table 2 has relationship on ID - one to many
Most Recent Teammate = CALCULATE ( MAX ( Table1[Teammate] ), TOPN ( 1, RELATEDTABLE ( Table1 ), Table1[Date] ) )
7 Replies
- SachinNandanwarImpactful Individual
Create a calculated column in first table that ranks the record across ID's
Rnk = RANKX ( FILTER ( 'Tbl_', 'Tbl_'[Id]= EARLIER (Tbl_[ID]) ), 'Tbl_'[Date], , DESC,Dense )
In the second table create a measure that retrieves the top most names across each ID's based on the rankRecent_TeamMate = CALCULATE ( MAX ( Tbl_[Name] ), FILTER ( RELATEDTABLE ( Tbl_ ), Tbl_[Rnk] = 1 ) ) - AnonymousNot applicable
Hi MuppetyMe
Thanks for the reply from parry2k and SachinNandanwar , please allow me to provide another insight:
The following measure is for your reference.
Measure = VAR _MAXDate = CALCULATE(MAX('Table1'[Date]), 'Table1'[ID] = MAX('Table2'[ID])) RETURN CALCULATE(MAX('Table1'[Teammate]), FILTER('Table1', [Date] = _MAXDate))Output:
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Kedar_PandeSuper User
In Table2, create a new calculated column
Recent Teammate =
CALCULATE(
FIRSTNONBLANK(Table1[Teammate], 1),
FILTER(
Table1,
Table1[ID] = Table2[ID] &&
Table1[Date] = CALCULATE(MAX(Table1[Date]), Table1[ID] = Table2[ID])
)
)