Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
cristian_av
Creator III
Creator III

Weighted average in Fact table

Hi

I have a fact table with the stipulated payment days of customers. These days are stipulated for each operation. I have the operations in a fact table and each operation can be repeated multiple times depending on the keys of dimensions...

I need to get this number:

Avg PaymentDays=(10*2+20*1+30*1)/4

   

Fact Table
CustomerOperationPaymentDaysKey1KeyN…
AA10x
AA10x
AB10x
AC30x
AC30x
AC30x
AD20x
AD20x
AD20x
AD20x

 

A resume of the fact table is like this (Just for you to understand the calculation)

DaysOperations (Count)
102
301
201

How should I do this calcution?

Thanks!!

1 Solution

Accepted Solutions
cristian_av
Creator III
Creator III
Author

Didn't work! It gives me a "-" as result

This expression worked:

Sum(PaymentDays * Aggr(Count(DISTINCT Operation), PaymentDays )) /

Count(DISTINCT Operation)

Thanks!

View solution in original post

2 Replies
sunny_talwar

May be this

Sum(Aggr(PaymentDays * Count(DISTINCT Operation), Customer, PaymentDays)/Count(DISTINCT Operation)

cristian_av
Creator III
Creator III
Author

Didn't work! It gives me a "-" as result

This expression worked:

Sum(PaymentDays * Aggr(Count(DISTINCT Operation), PaymentDays )) /

Count(DISTINCT Operation)

Thanks!