Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I get weighted sum?

Hi

I am trying to calculate the weighted sum. However

Aging     Cost     Weight by Cost           Weighted Aging

1               10        10/80                           1*(10/80)

2               30         30/80                          2*(30/80)

3               40         40/80                          3*(40/80)

Total         80         1                                   2.375

I'd like to get the result of 2.375. However, such number doesn't show but a symble "-" Coul d somebody help me on having the weighted sum calculated? Thanks!

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

Sorry, I didn't notice that your cost and your weight is the same thing - just try

Sum(Aging*Cost)/Sum(total Cost)

which probably is closer to what you want to do.

HIC

View solution in original post

4 Replies
Not applicable
Author

What I am using to get the Weighted Aging was

 

Sum

(Cost)/Sum (total <CURRENT_AREA> (Cost))*Aging

Should I do extra steps to get the total? Anyone knows how to do that?

hic
Former Employee
Former Employee

Normally, weighted averages are calculated through

Sum(Weight*Cost)/Sum(Weight)

And this formula would give a correct total also. But you want to us Aging also, which perhaps complicates it. But try

Sum(Aging*Weight*Cost)/Sum(Aging*Weight)

HIC

hic
Former Employee
Former Employee

Sorry, I didn't notice that your cost and your weight is the same thing - just try

Sum(Aging*Cost)/Sum(total Cost)

which probably is closer to what you want to do.

HIC

Not applicable
Author

Oh my god!

It took me hours of time trying to figure out how to use Aggr() and you solved in such a simple way!!! Big thanks!!