Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
richard_chilvers
Specialist
Specialist

Button to toggle selections

I wish to design a button which toggles between including and excluding a defined selection.

Whatever selections had already been made, the button would include data where (let's say) Field1 = 'A' and Field2 <> 'B'. When the button was clicked again, it would reverse this.

I have looked at using Toggle Select and also at Alternate States but I'm not clear whether these do the job.

I have considered having 2 buttons which are displayed conditionally, but this doesn't seem very elegant.

Any ideas would be welcome.

Thanks

1 Solution

Accepted Solutions
alexandros17
Partner - Champion III
Partner - Champion III

in the field (of select in field) write your field, in the bottom box write:

=If(GetFieldSelections(Field)='A', '<> B', 'A')

View solution in original post

4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

1) define a variable in the script: LET vToggle = '1';

2) Add the button: Write in the General Tab -> Text: If(vToggle=1, 'Condition 1', 'Condition 2')

3) in the Action Tab ->External -> Set variable Write in the upper box: vToggle, in the bottom box: If(vToggle=1,2,1)

4) in your chart (or table) write: If(vToggle=1, expression 1 (the one with field1 = A), expression 2 (The one with Field <> B)

let me know

richard_chilvers
Specialist
Specialist
Author

Hi Alessandro

That's a neat way to build a toggle button, and I have used something similar a few times. But what I am struggling to do is find the correct actions within the Button properties.. I can use Select in Field. But I do not know how to base the selection on the value of the toggle variable, vToggle.

alexandros17
Partner - Champion III
Partner - Champion III

in the field (of select in field) write your field, in the bottom box write:

=If(GetFieldSelections(Field)='A', '<> B', 'A')

richard_chilvers
Specialist
Specialist
Author

Wow, yes that seems to work.

That's a neat trick I have learnt today!

Thanks