cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dalla_Terra
Helper I
Helper I

Measure Will Not Sum in Table

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. 

 Screen Shot 2021-09-03 at 10.50.30 AM.png

Assistance is appreciated. 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

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

View solution in original post

4 REPLIES 4
BA_Pete
Super User
Super User

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

View solution in original post

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. 

Greg_Deckler
Super User
Super User

@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


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

goncalogeraldes
Solution Supplier
Solution Supplier

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.