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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Mainer04401
Helper III
Helper III

Filtering a column in SUMX to specific date for weighted average

Here's my issue: When showing the differences in weighted averages from one time period to another, sometimes I get unexpected results if the weights have changed between the two time periods being compared.  My potential solve for this is to compute the weight percentages using the same static time period, regardless of what time period is being filtered.  

 

Currently, I'm computing the weighted average as :
SUMX( 'Table',  [DiscountAmount] * [SalesVolume] ) / sum(SalesVolume)

 

I want both the SalesVolume column and SalesVolume measure to be filtered.  It's easy enough to filter the aggregate measure  by using something like CALCULATE(sum(SalesVolume), ALL('Calendar'))) but how do I do something similar to a column inside of SUMX?  

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file.  Explain the question and show the expected result in a Table format.


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

here is dax you can try :
Weighted Average =
VAR StaticSalesVolume = CALCULATE(SUM('Table'[SalesVolume]), ALL('Calendar'))
RETURN
SUMX('Table', [DiscountAmount] * CALCULATE('Table'[SalesVolume], ALL('Calendar'))) / StaticSalesVolume

If this helped, Follow this blog for more insightful information about data analytics
https://analyticpulse.blogspot.com/

Some blogs regarding dax:
https://analyticpulse.blogspot.com/2023/10/complex-real-life-dax-examples.html
https://analyticpulse.blogspot.com/2023/10/mastering-power-bi-dax.html
Please Subscribe AnalyticPulse on YouTube for future updates:
https://www.youtube.com/@AnalyticPulse
Please subscribe CogniJourney On Youtube For Daily fun facts:
https://www.youtube.com/@CogniJourney

Thanks but it's not letting me use CALCULATE without an aggregator like SUM, and if I use SUM inside a SUMX the totals are wrong because then it multiplies each row by the total sales instead of each row.  

can you share snip of error 

No error but the only things I can put inside CALCULATE are measures.  If I try to use a column it says cannot find name.  If I use SUM it will multiply every row by the total sales instead of that row's sales.  

are you using the column that is connected with other tables that are being used in dax?

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors