Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Passing ListBox selections to another (different) ListBox

Hi all,

   Let us suppose I have two different tables with the same content under different names (not linked to each other, and cannot be linked due to circular references), like:

  • Table A
    • Cod1
    • Desc1

  • Table B
    • Cod2
    • Desc2

   Now let us suppose I only have a ListBox for Table A, and I can only select Desc1. The question here is, is it possible when one selects something in Desc1 it will automatically select under Desc2 (a full name match is present).

   Sorry if this is somewhere available in documentation, but honestly I cannot find it.

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Hi andrlopes,

you can set up an "on select"- field event trigger on field Cod1:

settings --> doc props --> trigger --> choose "Cod1" and add (edit) action: there you have to add a "Select in Field" - action with "Cod2" as Field and

= '(' & getfieldselections(Cod1,'|') & ')'

//='(A|B)'

as search mask to search (and find!)  in Field Cod2 every time the same as in Cod1.

HtH

Roland

View solution in original post

20 Replies
Not applicable
Author

Hi andrlopes,

you can set up an "on select"- field event trigger on field Cod1:

settings --> doc props --> trigger --> choose "Cod1" and add (edit) action: there you have to add a "Select in Field" - action with "Cod2" as Field and

= '(' & getfieldselections(Cod1,'|') & ')'

//='(A|B)'

as search mask to search (and find!)  in Field Cod2 every time the same as in Cod1.

HtH

Roland

swuehl
MVP
MVP

Hi andrlopes,

yes I believe it is possible (If I understood you correctly).

There are some different approaches, some of them recently discussed here: http://community.qlik.com/message/149230#149230

, using Macros or actions to achieve a shadow copy of field selection.

I have attached my favorite, I use a document trigger (OnSelect trigger on field Desc 1) with an action Select in field with field [Desc 2] and search expression

='=sum({<[Desc 2]=[Desc 1]>} 1)'

Please see also attached sample. I added the listbox for Desc 2 to show the result of the copying though I believe you don't need it to get the selection in the field.

Hope this helps,

Stefan

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

That's a very cool approach using

='=sum({<[Desc 2]=[Desc 1]>} 1)'

I like it better than the concat() approach!

-Rob

Not applicable
Author

Hi Roland,

   Thanks, it worked like a charm!

Regards,

André

Not applicable
Author

Hi Stefan,

   Also helpfull!

Thanks,

André

Not applicable
Author

Hi,

   Thanks for your help, but I've been wondering if it's possible to do another thing. Imagine that I have selected something on a TableC selection box and it limits the values of Cod1 (despite no selection has been made on Cod1) and they turn grey (excluded). Is it possible to pass this Cod1 excluded values to Cod2 selection box? The goal is to have the same possible selection values on both Cod1 and Cod2, despite no selection has been made!

Ahanks again!

André

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can shadow the change to Cod1 by addin the same action to the OnChange trigger for Cod1. The concat() technique works for this, but the sum() technique does not. I'm not sure why.

-Rob

swuehl
MVP
MVP

Rob,

are you saying that you can explicitely set the selection state of field values to "possible" or "excluded" using that technique?

I tried with the concat method mentioned but didn't get it to work. It always resulted in a explicitely selected state of values (green), where I think Andre required it to be possibly selected (white).

If this (setting possible states) would be possible, wouldn't that break QV's logic easiliy, because you might set the possible selection state in a way which is not consistent?

Maybe I have misunderstood Andres request and the result of your solution is what is desired, or I have misunderstood what you suggested.

In my understanding one could only replicate the possible and excluded selection state in a duplicate table, if the duplicate, unlinked table is embedded in a data model which at least replicates the impacts to the original fields (i.e. Cod1 in this example) selection state in the original table (which might require to replicate the complete date model for the duplicate field (i.e. Cod2) in worst case?).

(Not sure if I make myself clear herewith...)

Regarding your last comment, I think you could maybe use the sum() technique in combination with p() function, I would try this

='=sum({<[Desc2] = p( [Desc1] ) >} 1)'

Best regards,

Stefan

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Stefan,

I was not suggesting that you can set possibles through an Action. I understood Andre's query to mean that his trigger was not getting fired when possibles of Desc 1 change because of another selection. OnChange will detect that condition, but I'm still making a selection on Desc 2.

I tried the

='=sum({<[Desc2] = p( [Desc1] ) >} 1)'

suggestion and it did not work. But you may be on the right track.

-Rob