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
ROBERTOCMRNO
Frequent Visitor

Weighed Average DAX Expression

I need a help...

I want to do this expressin dax, but I´m with problems in the days.

Someone help me?

Thank you.

Dúvida_.jpg

1 ACCEPTED SOLUTION

Hi @ROBERTOCMRNO,

 

Could you post your all table structures with some sample data in this case? Without knowing that we can only guess and offer possible suggestions.Smiley Happy

 

Normally, the DAX expression for Weighted Average should be similar like below.

[Average Med Age Weighted by Pop]=
SUMX(Zips, Zips[TTL Pop] * Zips[Med Age]) / [Total Population]

And

WAC = SUMX ( 'Analytics_SourceDat', [Net_Active_Balance] * [INTEREST_RATE] )
    / SUMX ( 'Analytics_SourceDat', [Net_Active_Balance] )

In addition, here is a similar thread, and here is a good article about Weighted Averages(DAX) for your reference.

 

Regards

View solution in original post

6 REPLIES 6
ChuQuangThang
New Member

Weighted Average PPM.JPG

austinsense
Impactful Individual
Impactful Individual

I'm getting a headache reading that Excel formula . Weighted average is pretty straigtforward in DAX.  The basic pattern looks like this ...

 

Weighted Average = SUM(one number) / SUM(other number)

You would write that as a new measure.  This is even better because it deals with the divide by zero.

 

Weighted Average = DIVIDE( SUM(one number), SUM(other number) )

Hope that helps.  The trick is to stop thinking in terms of cells and to start thinking in terms of columns.

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

Thank you for reply,

I tried this, but does not work...

The result of column MetaDiariaPonderada must be same the column Total.

The value of column MetaDiariaPonderada must be increase by the Column Dia.

Sem título.png

Hi @ROBERTOCMRNO,

 

Could you post your all table structures with some sample data in this case? Without knowing that we can only guess and offer possible suggestions.Smiley Happy

 

Normally, the DAX expression for Weighted Average should be similar like below.

[Average Med Age Weighted by Pop]=
SUMX(Zips, Zips[TTL Pop] * Zips[Med Age]) / [Total Population]

And

WAC = SUMX ( 'Analytics_SourceDat', [Net_Active_Balance] * [INTEREST_RATE] )
    / SUMX ( 'Analytics_SourceDat', [Net_Active_Balance] )

In addition, here is a similar thread, and here is a good article about Weighted Averages(DAX) for your reference.

 

Regards

Let me rephrase the original request into something a little different, and see how you would adjust your DAX formula.

I have a table named 'Advertising'
I have a Date column and a Cost column

I'm paying a flat fee of $4,000 for a single month. I want to create a calculated column, Fees, that displays the weighted amount of of that $4,000 for each Date's total Cost.

For example:
(I didn't fill in every cell, but you get the idea. I'm looking for a DAX formula to populate the Fees column.)

DateCostFees
4/1/2020100.0013.33
4/2/202050.006.67
4/3/2020845.00112.67
4/4/2020321.0042.80
4/5/202025.003.33
4/6/2020  
4/7/2020  
4/8/2020  
4/9/2020  
4/10/2020  
4/11/2020  
4/12/2020  
4/13/2020  
4/14/2020  
4/15/2020  
4/16/2020  
4/17/2020  
4/18/2020  
4/19/2020  
4/20/2020  
4/21/2020  
4/22/2020  
4/23/2020  
4/24/2020  
4/25/2020  
4/26/2020  
4/27/2020  
4/28/2020  
4/29/2020  
4/30/2020  
Totals30,000.004000.00

 

Hi,

Fill up with Cost column with numbers.  Also, is there a seperate table of the flat fee with a Date column?  Share that table (with 2 columns) as well. 


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

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.