Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

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. 

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!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
goncalogeraldes
Super User
Super User

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors