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

Use alternate field in expression

Hi everybody,

I'm using QS to compute the price of an engine and I'd like to compare it with the same engine that has some pieces replaces by others.

Imagine every engine (big object) is made up of different pieces (medium objects and small objects) and I'm using the following expression to compute the price of an engine:

Sum(Aggr((Sum([small_objects_quantity]*[medium_objects_quantity])*min(small_objects_price)), [small objects], [engine] ))

If I only select some small pieces I get the price of them multiplied by their quantities and there's no problem. Now I want to select some pieces in the main state and some in the alternate state to see how the total engine price changes.

I changed the expression and now I'm using this one:

Sum(Aggr((Sum([small_objects_quantity]*[medium_objects_quantity])), [small objects], [engine] ))*(Sum(Aggr(min(small_objects_price), [small_objects]))-Sum({Alt} Aggr(min({Alt} small_objects_price), [small_objects])))

So, in practice, I'm multiplying the quantities of a small object by the difference of the price of the old small object and the new small object. When I compute this with a single object it works, but when I select more objects to be changes the calculation goes wrong and I get bad results. I also thought about aggregating by the small objects, but this gives me zero for the price of the new objects and I really don't know what can I do to solve this.

What should I do?

Thanks for your help and your attention


Best regards


Nicolò Cogno

0 Replies