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
VinhTon
Helper I
Helper I

How to get grand total from Difference of monthly averages to provide sum not average?

sumOfAvgs.jpg

Desired result: get sum of Sales by workdays (sum of monthly diff) = 129,496 instead of 196,024.74

 

Background: trying to get the grand total sum of monthly difference between the average of sales by workdays. Have figured out all the parts including getting grand total of averages but it does not work with month;y differences. Ruled out hasonevalue as it works fine with sum of averages.

 

Thanks to the community help, I am confident about getting the sum of averages from this previous post. Don't know how to troubleshoot the sum of diff of avgs though.

 

Details

  • See pbix file
  • Sales by workday (avg): 
    DIVIDESUM(financials[Sales]), [Num Of Workdays] )
  • Sales by workday (sum avg): 

 

 

IF (
    HASONEVALUE ( 'Date'[Month Year] ),
    [Sales by Workdays (avg)],
    SUMX ( VALUES ( 'Date'[Month Year] ), [Sales by Workdays (avg)] )
)

 

 

  • Sales by Workday (avg prev month) =
    CALCULATE( financials[Sales by Workdays (avg)], PREVIOUSMONTH( 'Date'[Date] ) )
  • Sum of monthly diff =
    financials[Sales by Workdays (avg)] - financials[Sales by Workday (avg prev month)]
  • Sales by Workdays (sum of monthly diff) =
             var x = [Sales by Workday (monthly diff)]

    Return

                IF( HASONEVALUE( 'Date'[Month Year] ), x,

                SUMX( VALUES( 'Date'[Month Year] ), x )

    )
1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @VinhTon ,

 

Please simply use:

Sales by Workdays (sum of monthly diff) = SUMX(VALUES('Date'[Month Year]),[Sales by Workday (monthly diff)])

Eyelyn9_0-1651819483013.png

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

View solution in original post

6 REPLIES 6
v-eqin-msft
Community Support
Community Support

Hi @VinhTon ,

 

Please simply use:

Sales by Workdays (sum of monthly diff) = SUMX(VALUES('Date'[Month Year]),[Sales by Workday (monthly diff)])

Eyelyn9_0-1651819483013.png

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

Thanks you!

v-eqin-msft
Community Support
Community Support

Hi @VinhTon ,

 

You may try :

 

Measure = 
var _t= SUMMARIZE(ALLSELECTED(financials),financials[Month Year],"sum",[Sales by Workday (monthly diff)])
return IF(HASONEVALUE(financials[Month Year]) ,[Sales by Workday (monthly diff)],  SUMX(_t,[sum]))

 

 

If it still not work , please share me with your pbix file after removing sensitive data. Refer to:

How to Get Your Question Answered Quickly

How to provide sample data in the Power BI Forum

 

 

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

the result gave 6,175,653.92.
See pbix file. Thanks

johnt75
Super User
Super User

You could try

Sales by Workdays (sum of monthly diff) =
IF( ISINSCOPE( 'Date'[Month Year]), [Sales by Workday (monthly diff)],
SUMX( VALUES('Date'[Month Year]), [Sales by Workday (monthly diff)] )
)

Also gives 196,024

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.