Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
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 ID | CUSTOMER NAME |
1 | James |
2 | Joe |
3 | John |
Table 2
SALE | ITEM | CUSTOMER ID | SALE DATE |
1 | Apple | 1 | 1/1/2022 |
2 | Peach | 2 | 1/2/2000 |
3 | Apple | 1 | 1/5/2001 |
4 | Banana | 3 | 8/2/2021 |
5 | Peach | 1 | 1/2/2000 |
6 | Banana | 2 | 1/8/2000 |
Cheers
Rob
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.