Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
zagzebski
Creator
Creator

Upating Variables - Using Action in Button

I want to use the action in a button to do the following in order:


vVarable2 = if vVariable2 < vVariable1, vVariable1, vVarable2

vVarable3 = if vVariable3 < vVariable2, vVariable2, vVarable3

vVarable4 = if vVariable4 < vVariable3, vVariable3, vVarable4


I have 3 "Set Variable" actions in a button in this order:

Variable: vVarable2  Value: if vVariable2 < vVariable1, vVariable1, vVarable2

Variable: vVarable3  Value: if vVariable3 < vVariable2, vVariable2, vVarable3

Variable: vVarable4  Value: if vVariable4 < vVariable3, vVariable3, vVarable4


The problem (for example) is this:


Before I click button:

vVariable1 = 50

vVariable2 = 0

vVariable3 = 0

vVariable4 = 0


Click button first time:

vVariable1 = 50

vVariable2 = 50

vVariable3 = 0

vVariable4 = 0


Click button secondtime:

vVariable1 = 50

vVariable2 = 50

vVariable3 = 50

vVariable4 = 0


Click button third time - The result I want!

vVariable1 = 50

vVariable2 = 50

vVariable3 = 50

vVariable4 = 50


I want to be able to click the button once and get the result  of all variables being 50.





1 Solution

Accepted Solutions
swuehl
MVP
MVP

Or maybe like this?

1) vVariable2

=RangeMax(vVariable1, vVariable2)

2) vVariable3

=RangeMax(vVariable1, vVariable2,vVariable3)

3) vVariable4

=RangeMax(vVariable1, vVariable2,vVariable3,vVariable4)

View solution in original post

6 Replies
sunny_talwar

Can you check the attached and see if this is what you wanted?

UPDATE:

1) vVariable2

=If(vVariable2 < vVariable1, vVariable1, vVariable2)

2) vVariable3

=If(vVariable2 < vVariable1,

If(vVariable3 < vVariable1, vVariable1, vVariable3),

If(vVariable3 < vVariable1, vVariable2, vVariable3))

3)

=If(vVariable2 < vVariable1,

If(vVariable3 < vVariable1,

If(vVariable4 < vVariable1, vVariable1, vVariable4),

If(vVariable4 < vVariable3, vVariable3, vVariable4)),

If(vVariable4 < vVariable2, vVariable2, vVariable4))

I would suggest checking the results in other scenarios as well to make sure that this is working in all cases.

Best,

Sunny

swuehl
MVP
MVP

Or maybe like this?

1) vVariable2

=RangeMax(vVariable1, vVariable2)

2) vVariable3

=RangeMax(vVariable1, vVariable2,vVariable3)

3) vVariable4

=RangeMax(vVariable1, vVariable2,vVariable3,vVariable4)

maditre1
Luminary
Luminary

Hi,

With small correction to swuehl reply, try the following code. It is working as per your requirement.

1) vVariable4

=RangeMax(vVariable3, vVariable4)

2) vVariable3

=RangeMax(vVariable3,vVariable2)

3) vVariable2

=RangeMax(vVariable2,vVariable1)

Thanks,

Reshma M.

zagzebski
Creator
Creator
Author

Very helpful. Thanks!

Zag

zagzebski
Creator
Creator
Author

Thanks so much!

Zag

sunny_talwar

No problem at all. I am glad we were able to help