Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have two tables:
I want to look up the newest value in Table 2 and add it as a new column in Table 1.
See below tables for the desired output:
Solved! Go to Solution.
Hi @mober ,
Try to create a calculated column like so:
Latest Location =
VAR LatestDate =
CALCULATE (
MAX ( 'Table 2'[Date] ),
FILTER ( 'Table 2', 'Table 2'[ID] = EARLIER ( 'Table 1'[ID] ) )
)
RETURN
CALCULATE (
MAX ( 'Table 2'[Location] ),
FILTER (
'Table 2',
'Table 2'[Date] = LatestDate
&& 'Table 2'[ID] = EARLIER ( 'Table 1'[ID] )
)
)
BTW, .pbix file attached.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @mober ,
Try to create a calculated column like so:
Latest Location =
VAR LatestDate =
CALCULATE (
MAX ( 'Table 2'[Date] ),
FILTER ( 'Table 2', 'Table 2'[ID] = EARLIER ( 'Table 1'[ID] ) )
)
RETURN
CALCULATE (
MAX ( 'Table 2'[Location] ),
FILTER (
'Table 2',
'Table 2'[Date] = LatestDate
&& 'Table 2'[ID] = EARLIER ( 'Table 1'[ID] )
)
)
BTW, .pbix file attached.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@mober ,
latest location = LastNONBLANKVALUE(table2[Date], MAx(Table2[Location]))
make sure two tables have joins to display data together
I am getting the same value for all IDs, even though the two tables are joined on the ID
As a MEASURE you could do this and use in a matrix visual:
Latest Location =
VAR _lastDate = MAX(Table2[Date])
RETURN MAXX(FILTER(Table2, Table2[Date]=_lastDate), Table2[Location])
or
Latest Location =
VAR _lastDate = MAX(Table2[Date])
RETURN CALCULATE(SelectedValue[Table2[Location]), (FILTER(Table2, Table2[Date]=_lastDate))
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Thank you for your solution @AllisonKennedy .
However, I will need the value in a column in order for the data to interact correctly between multiples tables.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@AllisonKennedy The cross filter direction is already set to "Both", but I am receiving blank rows when using the formulas you provided.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |