Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everybody, I need your help for this apparently simple problem.
SUMX(Batch,
CALCULATE(
MAX(MetalValues[Value]),
TREATAS(VALUES(Batch[Metal]), MetalValues[Metal]),
TREATAS(VALUES(Batch[Date]), MetalValues[Date])
)
)
The Batch table contains a list of production Dates of different Metals. I need to retrieve the Price for those dates and metals from the unrelated MetalValues table and sum them up.
The issue is that, at each iteration of SUMX, the MAX function returns the max value of the whole MetalValues table. My expectation and need is that it only returned the MetalValue value from that Date and Metal (which is unique being a daily trading value).
Any idea on what's my mistake here?
Thanks
Fil
Solved! Go to Solution.
Please try this measure expression instead
New Measure =
VAR summary =
ADDCOLUMNS (
SUMMARIZE ( Batch, Batch[Metal], Batch[Date] ),
"@value",
VAR thisdate = Batch[Metal]
VAR thismetal = Batch[Metal]
RETURN
CALCULATE (
MAX ( MetalValue[Value] ),
MetalValue[Metal] = thismetal,
MetalValue[Date] = thisdate
)
)
RETURN
SUMX ( summary, [@value] )
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks for your answers. The original pbix contains some confidential data, I'm attaching a screenshot of the two tables, hope it helps. The first one is the Batch table, the second it MetalValues, where the values should be retrieved from.
I thought maybe there was a mismatch in the Date field, but they both appear formatted as Dates.
Thanks!
Batch
MetalValues
Please try this measure expression instead
New Measure =
VAR summary =
ADDCOLUMNS (
SUMMARIZE ( Batch, Batch[Metal], Batch[Date] ),
"@value",
VAR thisdate = Batch[Metal]
VAR thismetal = Batch[Metal]
RETURN
CALCULATE (
MAX ( MetalValue[Value] ),
MetalValue[Metal] = thismetal,
MetalValue[Date] = thisdate
)
)
RETURN
SUMX ( summary, [@value] )
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@OnlyPhilip ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Appreciate your Kudos.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
19 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
25 | |
10 | |
10 | |
9 | |
6 |