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
sidh86
New Member

Incorrect summation of a measure

Hi everyone,

 

Relatively new Power BI user here. I have seen similar threads on the forum but for the life of me can't apply it to my situation.


I am trying to create a measure "Hours Available", which takes my hours available in a work day from my Calendar table (8 hours a day for every weekday), and multiplies it by the count of my users in a different table for a given time period. My formula is as follows:

 

Hours Available =
SUM('Date'[Hours]) * DISTINCTCOUNT('Avaza_TimesheetEntry_2018 (2)'[Assigned User])

 

What I'm finding is that the formula evaluates correctly for each row, but the summation is off (see example below - the sum of Hours Available should actually be 5,720). The problem seems to be that the Distinct Count of users for the summation row is counting the max number of users in the table, rather than taking the sum of each of the evaluated rows. This produces a difference because some users were not employees during certain weeks (e.g. their start dates were in Week 3 rather than Week 1). Is there a way for the summation to reflect the sum of each evaluated row, rather than to recalculate the formula with the count of users in the table across all weeks?

 

Based on reading through some other threads, I'm wondering if it's the use of SUM vs. SUMX, but if that's the case, I can't seem to figure out the correct syntax.

 

Thanks in advance,

Sid

 

 Summation Error.JPG

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Try this measure

 

=SUMX(SUMMARIZE(VALUES(Date[Week]),[Week],"ABCD",SUM('Date'[Hours]) * DISTINCTCOUNT('Avaza_TimesheetEntry_2018 (2)'[Assigned User])),[ABCD])

 

I have assumed that the Week columnin your visual is from the Date Table.  If not, then please change the reference in my formula.  If this formula does not give the correct result, then share the link from where i can download your file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

Try this measure

 

=SUMX(SUMMARIZE(VALUES(Date[Week]),[Week],"ABCD",SUM('Date'[Hours]) * DISTINCTCOUNT('Avaza_TimesheetEntry_2018 (2)'[Assigned User])),[ABCD])

 

I have assumed that the Week columnin your visual is from the Date Table.  If not, then please change the reference in my formula.  If this formula does not give the correct result, then share the link from where i can download your file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

This worked! Thanks Ashish! If you're able to, could you walk me through the logic of your formula? I don't quite follow along (still a newbie!)

You are welcome.  I'd request you to please read up on the SUMMARIZE function.  If you still have doubts, post back.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149


@ 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...

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.