Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Lookup duplicate records, bring the latest record

Hello

 

I am looking for a way, with Power Query, DAX, Measure or new Column, without eliminating duplicates, to bring me the latest record (the newest date) between two tables E.g.

 

Table 1 Table 2
IDDateProfile IDTest ResultLast Profile Result
XYZ01/01/2022Proactive XYZApprovedIntrovert
XYZ02/01/2022Proactive ABCApprovedGoal Oriented
XYZ03/01/2022Introvert HIJApprovedIntuitive
ABC03/01/2022Goal Oriented    
ABC01/01/2022Proactive    
ABC02/01/2022Intuitive    
HIJ02/01/2022Goal Oriented    
HIJ03/01/2022Intuitive    
HIJ01/01/2022Proactive    

 

I need to retrieve the latest information from table #1, Profile Column (the newest date), to table #2 in the Column Last Profile Result.

Regards

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous ,

 

You could first add a rank column in the Table 1 to get the earliest date. Then merge two tables.

Here's the steps.

1.Sort the Date column.

vstephenmsft_0-1657095040663.png

vstephenmsft_3-1657095094337.png

 

2.Group by the ID column

vstephenmsft_1-1657095063777.png

vstephenmsft_2-1657095075420.png

 

3.Add a custom column to get the ranking.

vstephenmsft_4-1657095113899.png

 

4.Expand the column, remove the unneeded column.

vstephenmsft_5-1657095138877.png

 

5.In the Table 2, merge with the Table 1.

vstephenmsft_6-1657095170861.png

vstephenmsft_10-1657095269546.png

 

 

6.Expand the columns, filter the row with rank 1.

vstephenmsft_7-1657095240044.pngvstephenmsft_8-1657095257188.pngvstephenmsft_9-1657095262682.png

vstephenmsft_11-1657095315007.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

wdx223_Daniel
Super User
Super User

in Table 2,

NewStep=let a=Table.Buffer(Table.Group(Table1,"ID",{"n",each Table.Max(_,"Date")[Profile]})) in Table.AddColumn(PreviousStepName,"Profile Result",each a{[ID=[ID]]}?[n]?)

Anonymous
Not applicable

I do not know if is my version of PBI or what but it is showing me an "Expression.Error" with 'previousStepName'

 

By the way tahnk you so much for your reply

KT_Bsmart2gethe
Impactful Individual
Impactful Individual

Hi @Anonymous ,

 

Power Query:

In Table 2, add a custom step (not add a custom column) and apply the formula below:

= Table.AddColumn(#"Changed Type", "Last Record", (x)=> List.Max(Table.SelectRows(Table1, each (x[ID]=[ID]) and (x[Last Profile Result]=[Profile]))[Date]))

 

Regards

KT

 

Anonymous
Not applicable

@KT_Bsmart2gethe It marks an "Expresion.Error" with the ´changed Type´ part, it did not recognize it.

 

Thank you for your Reply by the way

Hi @Anonymous ,

 

I do apologise for not providing clear instructions. 

 

You must replace the #"Changed Type" with the previous step name. 

Say if your previous step name is "Source", then you will need to change it to Source; if the previous step name is "Added Column", then you will need to replace the provided name with #"Added Column" (You will need to use #"xxxif the name contains space)

The same concept applies to the solution code provided by @wdx223_Daniel, and you will need to replace the"PreviousStepName" with the actual name from the previous step to have it works.

 

I hope it is clear for you and ensuring your challenge is resolved. 🙂

 

Regards

KT

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.