Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I know versions of this question have been posted but having gone through several examples, none are working with my issue.
Keep in mind that the YTD Sales field and the Goal field do sum on their own in other tables I have them in but for some reason when used in my IF statement they will not sum.
I have the following measure, which is a simple IF statement but it will not sum in my table:
Goal Achieved = If([YTD Sales]/[Goal]>1,1,0)
The YTD Sales field is itself a measure, which is written as:
YTD Sales = Sumx(Values(Dates[Year]),TOTALYTD(sum(Depletion[Total Sales]),Dates[Date]))
The Goal field is a measure as well and is written as:
Goal = Sumx(Values(Dates[Year]),TOTALYTD(sum('Goals'[Target_Goal]),Dates[Date]))
When I add this measure to my Table it works great except that it is not summing. I get the output below, which as you can see there is one value that is 1, the rest are 0 but the sum is still zero.
Assistance is appreciated.
Solved! Go to Solution.
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
Proud to be a Datanaut!
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
Proud to be a Datanaut!
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.
@Dalla_Terra This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
Hello there @Dalla_Terra ! Unfortunately the Power BI table/matrix sometimes performs poorly when adding the column totals. Try using the Acterys Matrix Visual!
https://appsource.microsoft.com/en-us/product/power-bi-visuals/wa104381371?tab=overview
Hope this answer solves your problem! If you need any additional help please tag me in your reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️ or give it a kudoe 👍
Thanks!
Best regards,
Gonçalo Geraldes