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

Help calculate max price on layout

Hello ,

i have a problem with my expression in the layout.

I have a straight table and i calculate price and sales with variables which are definied in the layout.

Example :

productnr                     Price      Sales

1234                           101,4      3400

1234                           120,5      2000

1234                           130,6      4000

1234                           125.8      5000

Now i want to calculate the price with the best Sales for the product, but my expression doesn't work...

my expression:

(max ({$<vSales={$(=max(vSales))}>} vPrice )

Anyone an idea ?

5 Replies
SunilChauhan
Champion
Champion

use below code

max({<Sales={$(=Max(Sales))}>}Price)

see the attached file

hope this helps

Sunil Chauhan
Not applicable
Author

Yes this example works, but i use calculated variables in this expression and than it doesn't work..can it be that in qlikview the setanalysis expression not works with caculated variables?

SunilChauhan
Champion
Champion

no its not like that it will work

create a variable vMax=Max(Sales)

then use

max({<Sales={$(vMax)}>}Price) in expression

see the attached file

Sunil Chauhan
Not applicable
Author

I tested it in my script but i can't use Sales and Price like a field in your example. I must use my variables

and when i write :

Variables: vSales : sum(set analysis expression

                vPrice : vSales/Field

                vMax : max(sum(set analysis expression)

max({<vSales={$(vMax)}>}vPrice)

it doesn't work and my syntax checker in the expression red lined the second {

SunilChauhan
Champion
Champion

in condtion we required to have a field and a variable .not two variable

ex:

{<vSales={$(vMax)}

it should not work.

can share sample i will look into it

hope this helps

Sunil Chauhan