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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. 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
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.