Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
helen_pip
Creator III
Creator III

One button to contain 2 values

Dear Qlikview user

I have a button which I would like the user to be able to click on, and each time they click on the button the wording would say either:

'Compared to Previous FY YTD:' OR

'Compared to Previous Month'


I have the following expression


=If(v_Selected = 1,

'Compared to Previous FY YTD:',

If(v_Selected = 2,

'Compared to Previous Month'))

and 2 actions on the button where set variable = v_Selected = 1 and

                                                  set variable = v_Selected =2

But unfortunately my button isn't working

I am trying to stay away from show/hide and the number of objects within my document, so was wondering if anyone could help me obtain this result with just one button object instead

Any help would be greatly appreciated

Thanks

Helen

1 Solution

Accepted Solutions
sunny_talwar

Set you variable like this

v_Selected


Definition

=If(v_Selected = 1, 2, 1)

The variable will not toggle between 1 and 2 every time you click on the button. Now you can set your expression/dimension with values of 1 and 2.

View solution in original post

8 Replies
sunny_talwar

You are setting the same variable 2 values? I think if you select the button, it will only be saved with one value. What exactly is your goal here?

helen_pip
Creator III
Creator III
Author

Hello SunnyT

Thanks for your response

I have a table which shows data by Financial Year.  I now want to show the same table but by data by Previous Month

I would like just one button which if the user clicks on it, then they will either see data by Financial Year or by clicking again, data by Previous Month

My aim is to have one graph and one button to control whether the user views data by Financial Year or Previous Month

My aim is to reduce the number of objects by 1/2 using this technique

Any help would be greatly appreciated

Kind Regards

Helen

sunny_talwar

Set you variable like this

v_Selected


Definition

=If(v_Selected = 1, 2, 1)

The variable will not toggle between 1 and 2 every time you click on the button. Now you can set your expression/dimension with values of 1 and 2.

rupamjyotidas
Specialist
Specialist

Don't use button for this:

Use Inline Tables:

You can get a List Box as Below and Now you can use GetFieldSelection(CTP) function in your Conditional Box

helen_pip
Creator III
Creator III
Author

Perfect!

Thanks so much!  I have done this before in other things and didn't think to use the same technique here aswell

Thank you!

Thanks

Helen

sunny_talwar

Not a problem, I am glad I was able to help

Best,

Sunny

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I'd suggest replacing the 1/2 values with 1/0 values and use a single Actions: Set Variable:

vSelected = 1-vSelected

That will create the flip-flop action that you are looking for,

cheers,

Oleg Troyansky

Learn advanced QlikView and Qlik Sense techniques in my book QlikView Your Business.

awhitfield
Partner - Champion
Partner - Champion

Hi Helen,

for the button text:

=if(v_Selected=1,'Compared to Previous FY YTD','Compared to Previous Month')

HTH

Andy