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
JPY
Helper II
Helper II

Sum of Measure is wrong

Hi all,

I was trying to come up with a measure to sum up the amount. It returns the correct number for each row, however, the total is not correct. Does anyone know how to go about doing it?

 

Measure = IF(DISTINCTCOUNT('Table'[Merged])>1,DIVIDE(sum('Table'[Amount]),DISTINCTCOUNT('Table'[Merged])),SUM('Table'[Amount]))

 

Table:

AmountBookedMerged
1734887.59321486532016-38736 1 001001006
1734887.59321486532016-38737 1 001001006
484259321489442016-39663 1 001013000
2656296321759432017-103708-3 1 001001020
2261870321759482017-103708-3 2 S001001002

HELP.PNG

Here is the link of the pbix sample: 

https://drive.google.com/open?id=10hGBZUKJ2ud9CtUpjOs6WQIQvKMvgaZw

 

 

Thank you!

JPY

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @JPY ,

 

The total isn't the sum of the measure, it's the result of all amount being calculated by your formula.

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
richbenmintz
Solution Sage
Solution Sage

Hi @JPY ,

 

I think this is an issue of granularity of the data at the row level of the table the data is calculated correctly, however at the grand total the distinct counts are all 1, if you create t following measures you will see how you can make the total work properly with sumx

 

dist_count = DISTINCTCOUNT('Table'[Merged])

 

 

 

divide_by_dist = if(DISTINCTCOUNT('Table'[Booked]) = 1, [Measure], sumx(VALUES('Table'[Booked]),[measure])/[dist_count])

 

 

sumx.png



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


amitchandak
Super User
Super User

Try

Measure =
sumx(summarize('Table','Table'[Booked],"_sum",sum('Table'[Amount]),"_dist",DISTINCTCOUNT('Table'[Merged]))
	if(_dist>1 , divide(_sum,_dist),_sum))

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Anonymous
Not applicable

Hi, I understand your confusion. 

 

The calculation for total is represented by your measure: 

 

DIVIDE ( 8.872.200,18 / 5 ) 

 

Gives you 1.774.440,04; which is correct! 

 

Basically adding your original "Amount", will help here to understand your problem.

Knipsel.PNG

 

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.