Qlik Community

Ask a Question

New to QlikView

If you’re new to QlikView, start with this Discussion Board and get up-to-speed quickly.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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

May be you need this

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

Capture.PNG

View solution in original post

4 Replies

May be you need this

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

Capture.PNG

View solution in original post

Creator III
Creator III

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

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?

Creator III
Creator III

Yes, a lot of sense. Thanks!