Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
cristian_av
Creator III
Creator III

Multiple Cost by Kg shows incorrect Value

Hi

I have a table of cost by kg, for multiple types of cost. There are costs for each combination of: Year,Product Group, Real Product and Package Type.

I also have a table of products, and each product has multiple cost by kg related.

I need to calculate the cost by kg for each product, and it's associated dimensions (Such as real product, rotulated product...), but I'm getting incorrect values when I use dimensions that are not the "keys" dimensions of the costs. (Year,Product Group, Real Product and Package Type.)

I've uploaded an example with the data and the expression that I am using.

How should I calculate the cost by Kg?

Thanks!!

1 Solution

Accepted Solutions
sunny_talwar

May be you need this

=Sum([Cost by Kg] * Kg)/Sum(Kg)

Capture.PNG

View solution in original post

4 Replies
sunny_talwar

May be you need this

=Sum([Cost by Kg] * Kg)/Sum(Kg)

Capture.PNG

cristian_av
Creator III
Creator III
Author

Thanks!

Dumb of me..

I've tryied with a similar expression:

Sum([Cost by Kg])*Sum(Kg)

But with incorrect values. Could you pleas explain to me what is the difference with the following:

Sum([Cost by Kg] * Kg)

I ask, because in many cases both expression gave me the same values.

Thanks Sunny

sunny_talwar

Expression 1 will Sum Cost by Kg based on your dimension and then multiply it with Sum of Kg. Second expression will first multiply Cost by Kg and Kg per row and then sum it for each of your dimension.

Does that make sense?

cristian_av
Creator III
Creator III
Author

Yes, a lot of sense. Thanks!