Forum Discussion
Get latest value for relationship
Hi all,
I have three different tables with
- Devices
- Sender
- Connections (which device is on which sender)
As the connections table does not only hold current connections but also historic data I need to create a table out of that only holding the latest connection per device.
Looking my example above I need to extract one line per "device_id" with the latest "registration_date". Usually the "deregistration_date" is empty so it could be sufficient to filter by empty "deregistration_date" but I am looking for safe implementation filtering the latest "registration_date".
Any idea on how to to that in the Power Query? I think it needs to be done there in order to be able to user that result in the relationships later.
Thx a lot!
- Anonymous5 years ago
p1ngu1n
Please refer to my recent blog, scroll down to Scenario 2, you just need to change the top 3 latest days to the top 1 by using the following code.Table.FirstN(Table.Sort(_, {{"Date", Order.Descending}}),1)Blog: Dynamically Display the Most Recent N Days using P... - Microsoft Power BI Community
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandakSuper User
p1ngu1n , You can create a new flag in dax like
new column = if([registration_date] = maxx(filter(Table, [device_id] = max([device_id])),[registration_date]),1,0)
for power query refer
https://www.excelguru.ca/blog/2016/05/25/keep-the-most-recent-entry/
https://exceleratorbi.com.au/remove-duplicates-keep-last-record-power-query/
- AnonymousNot applicable
p1ngu1n
Please refer to my recent blog, scroll down to Scenario 2, you just need to change the top 3 latest days to the top 1 by using the following code.Table.FirstN(Table.Sort(_, {{"Date", Order.Descending}}),1)Blog: Dynamically Display the Most Recent N Days using P... - Microsoft Power BI Community
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.