cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

WEIGHTED AVG

Hi,  I am having difficulty created a weighted avg measure (balance*int rate) and tried creating a helper column to no avail. I am new to PBI and would appreciate assistance.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Skilled Sharer
Skilled Sharer

Re: WEIGHTED AVG

SUM([Net_Active_Balance])

 

not SUM('Analytics_SourceDat',[Net_Active_Balance])

 

perhaps?

---
In Wisconsin? Join the Microsoft BI Professionals - Wisconsin group.

View solution in original post

12 REPLIES 12
Highlighted
Super User IV
Super User IV

Re: WEIGHTED AVG

Need to see your data. You should just be able to do something like:

 

SUM([balance]*[int rate])/COUNT([balance])

 

 


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Regular Visitor

Re: WEIGHTED AVG

Hi,

 

Thanks for responding ,  the fields include balance & rate.  Tried WAC = SUM([Net_Active_Balance]*[INTEREST_RATE]) / SUM([Net_Active_Balance])

 

However, the syntax doesn't work to arrive at the weighted avg rate since I get this error:

 

The SUM function only accepts a column reference as an argument.

Highlighted
Skilled Sharer
Skilled Sharer

Re: WEIGHTED AVG

In this situation, you want to use SUMX rather than SUM.

 

SUMX('Table',[Net_Active_Balance]*[INTEREST_RATE])

 

(replacing table with the name of your table)

 

The SUMX means that it will multiple the balance by the interest rate for each row and then sum the result. There's a great blog post here that breaks it down: http://www.powerpivotpro.com/2014/10/sum-sumx-or-calculatechoices-choices/

---
In Wisconsin? Join the Microsoft BI Professionals - Wisconsin group.
Highlighted
Regular Visitor

Re: WEIGHTED AVG

Methinks I got it...

 

 

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

Highlighted
Regular Visitor

Re: WEIGHTED AVG

Wow-  just as you posted, i got it to work after some trial n error with some googling!  Thank you.

Highlighted
Skilled Sharer
Skilled Sharer

Re: WEIGHTED AVG

You're welcome.

 

You also don't need a SUMX for the divider since that's a straightforward SUM of the Net_Active_Balance.

 

(SUMX works row-by-row, so performs slower than a straightforward SUM)

---
In Wisconsin? Join the Microsoft BI Professionals - Wisconsin group.
Highlighted
Regular Visitor

Re: WEIGHTED AVG

Good point-  appreciate the support! 

Highlighted
Regular Visitor

Re: WEIGHTED AVG

Just modified to SUM, but got error msg-  is this a syntax error in formula?

 

"Too many arguments were passed to the SUM function. The maximum argument count for the function is 1."

Highlighted
Skilled Sharer
Skilled Sharer

Re: WEIGHTED AVG

SUM([Net_Active_Balance])

 

not SUM('Analytics_SourceDat',[Net_Active_Balance])

 

perhaps?

---
In Wisconsin? Join the Microsoft BI Professionals - Wisconsin group.

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors