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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
rjtedge
Frequent Visitor

Return most recent record from another table

Hi, 

 

I have two tables in power bi. Table 1 is a list of customers, Table 2 has a list of sales. I want to create a new column in Table 1 that contains the most recent sale item for each customer. Can't seem to make it work with DAX. 

 

Table 1

CUSTOMER IDCUSTOMER NAME
1James
2Joe
3John

Table 2

SALEITEMCUSTOMER IDSALE DATE
1Apple11/1/2022
2Peach21/2/2000
3Apple11/5/2001
4Banana38/2/2021
5Peach11/2/2000
6Banana21/8/2000

 

Cheers

Rob

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

Create a relationship (Many to One and Single) from Table2 to Table1.  Create a Calendar Table and a relationship (Many to One and Single) from the Sale Date of Table2 to the Date column of the Calendar Table.  To your Table visual, drag the fields from Table1.  Write these measures

Farthest date = max('Table2'[Sale date])

Last item bought = calculate(min('Table2'[Item]),datesbetween(Calendar[Date],[Farthest date],[Farthest date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors