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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
I'm trying to create a new table that shows the cost of the most recent purchase of 'Product 1', per customer. I've tried a formula using summarize with filter and max date but just not quite getting there. Below is some sample data and the desired result.
Thanks for looking...
Solved! Go to Solution.
New Table =
ADDCOLUMNS (
TREATAS (
GROUPBY (
FILTER ( Data, Data[product] = 1 ),
Customers[customer],
Products[product],
"@datemax", MAXX ( CURRENTGROUP (), Data[date] )
),
Data[customer],
Data[product],
Data[date]
),
"@cost", CALCULATE ( SUM ( Data[cost] ) )
)
New Table =
ADDCOLUMNS (
TREATAS (
GROUPBY (
FILTER ( Data, Data[product] = 1 ),
Customers[customer],
Products[product],
"@datemax", MAXX ( CURRENTGROUP (), Data[date] )
),
Data[customer],
Data[product],
Data[date]
),
"@cost", CALCULATE ( SUM ( Data[cost] ) )
)
Many thanks, worked perfectly!
Another way of calculation:
[Your table] = // calulated table
CALCULATETABLE(
var Filter_ =
ADDCOLUMNS(
DISTINCT( T[Customer] ),
"Date", CALCULATE( MAX( T[Date] ) )
)
var Result =
CALCULATETABLE(
T,
TREATAS(
Filter_,
T[Customer],
T[Date]
)
)
return
Result,
T[Product] = "product 1"
)
Thanks Daxer for taking the time to help, works perfectly.
[Your table] = // calulated table
CALCULATETABLE(
GENERATE(
SUMMARIZE(
T,
T[Customer],
T[Product],
),
SELECTCOLUMNS(
CALCULATETABLE(
TOPN(1,
T,
T[Date],
DESC
)
),
"Date", T[Date],
"Cost", T[Cost]
)
),
T[Product] = "product 1"
)
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 21 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 35 | |
| 31 | |
| 19 | |
| 13 | |
| 10 |