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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.