Forum Discussion
Measure Will Not Sum in Table
- 4 years ago
Hi Dalla_Terra ,
This is a common misunderstanding about how tables work in Power BI.
The totals row DOES NOT sum the values in the columns above it, rather it calculates the measure in the column above it WITH NO FILTERS.
Try rewriting your measures something like this:
YTD Sales = CALCULATE( SUM(Depletion[Total Sales]), DATESYTD(Dates[Date], "31/03") //In quotes will be the last day/month of your 'year' ) YTD Goal = CALCULATE( SUM(Goals[Target_Goal]), DATESYTD(Dates[Date], "31/03") ) Goal Achieved = SUMX( Depletion, VAR __achieved = [YTD Sales] / [Goal] RETURN (__achieved > 1) * __achieved )I've kind of done this off the top of my head as I can't see exactly how your model is set up, but the main take-away is that your table totals don't just sum the column values, so you need to use an iterator (SUMX, COUNTX etc.) around your calculation to get the individual results to sum.
Pete
Hi Dalla_Terra ,
This is a common misunderstanding about how tables work in Power BI.
The totals row DOES NOT sum the values in the columns above it, rather it calculates the measure in the column above it WITH NO FILTERS.
Try rewriting your measures something like this:
YTD Sales =
CALCULATE(
SUM(Depletion[Total Sales]),
DATESYTD(Dates[Date], "31/03") //In quotes will be the last day/month of your 'year'
)
YTD Goal =
CALCULATE(
SUM(Goals[Target_Goal]),
DATESYTD(Dates[Date], "31/03")
)
Goal Achieved =
SUMX(
Depletion,
VAR __achieved = [YTD Sales] / [Goal]
RETURN
(__achieved > 1) * __achieved
)
I've kind of done this off the top of my head as I can't see exactly how your model is set up, but the main take-away is that your table totals don't just sum the column values, so you need to use an iterator (SUMX, COUNTX etc.) around your calculation to get the individual results to sum.
Pete
Thank you, this worked, though I did have to make some changes to the measures to get the output I was looking for.
I ended up using SUMX in the YTD Sales and YTD Goal measures.
I then wrote the Goal Achieved as:
Goal Achieved = If(SUMX('Depletion',[YTD Sales] / [Target Goal]) >=1,1,0)
Using VAR resulted in everything showing up as "0", even for the value which was clearly not.
I am not sure but one thing I did not mention was that the YTD Sales measure and YTD Goal measure are in two different tables, which may be why the issue was ocurring.
Regardless, changing things up as I did gave me the result I needed.
Thank you for the coaching.