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.
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.
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 |
---|---|
104 | |
95 | |
80 | |
67 | |
62 |
User | Count |
---|---|
138 | |
107 | |
104 | |
82 | |
63 |