Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

3 Lists, 1 Removes, 1 Adds and 1 Result

Hey Guys, I need a help in here.

I have 3 lists like these:

List 1 (Removes from Result when Selected)List 2 (Adds on Result when Selected)List 3 (Result)
Optional 1Optional 1Optional 1
Optional 3Optional 2Optional 3
Optional 4Optional 3Optional 4
Optional 6Optional 4Optional 6
Optional 9Optional 5Optional 9
Optional 13Optional 6Optional 13
Optional 19Optional 7Optional 32
Optional 27Optional 8Optional 40
Optional 32Optional 9Optional 2
Optional 40Optional 10Optional 12
Optional 11Optional 14
Optional 12Optional 15
Optional 13
Optional 14
Optional 15

The thing is:

The 'RESULT LIST' has EVERYTHING that the 'LIST 1' does, although, what is selected on 'LIST 1' removes from the 'RESULT LIST' (It's like if you have those Optionals already pre-selected but you have to say which one you DON'T WANT TO, like buying a car.)

And the 'LIST 2' does the Opposite, it has ALL the Optionals, from 1 to 99 we can say, and when selected, it ADDS to the 'RESULT LIST' instead of removing it like 'LIST 1' does.

So, in the example above I'm:

REMOVING the 'Optional 19' and the 'Optional 27' from the 'RESULT LIST' you can see those selections don't appear there AND

ADDING the 'OPTIONAL 2, 12, 14 and 15' from the 'LIST 2' to the 'RESULT LIST'.

Thank you in advance!

1 Solution

Accepted Solutions
Not applicable
Author

Ok, well I did not thought of your approach. This looks great to me.

To resolve it, you can use below expression for vPre_OPT variable

=replace(chr(39)&Concat({1-$}[OPTIONALS PRE-SELECTED], ',') &chr(39),',',chr(39)&','&chr(39))

And then =ValueList($(vPRE_OPT),$(vALL_OPT))

Thanks,

Angad

View solution in original post

6 Replies
Not applicable
Author

Can you please attach a sample QVW file with expected results. That will help you get quick answers.

-Angad

Not applicable
Author

Sure, there we go.

So, I left some selections already like this:

List 1 PRE-SELECTED (Removes when Selected)List 2 ALL OPTIONALS (Adds when Selected)Result
Optional 1Optional 3(Everything on List 1, REMOVING the Red Selections)
Optional 14Optional 4Optional 3
Optional 15Optional 5Optional 4
Optional 16Optional 6Optional 5
Optional 26Optional 7Optional 6
Optional 28Optional 8Optional 7
Optional 37Optional 19Optional 8
Optional 27Optional 20Optional 19
Optional 39Optional 21Optional 20
Optional 41Optional 30Optional 21
Optional 42Optional 1Optional 30
Optional 43Optional 2

So, the 'RESULT LIST' should have everything on 'LIST 1' without the Selections PLUS Adding the Selections from 'LIST 2'.

Not applicable
Author

Hello,

Please find the attached document. This is one such way, which came up in my mind.

We are setting values of selected fields into variables and then passing these variables at the script.

Hope it helps.

Thanks,

Angad

Not applicable
Author

Thank you for replying, your idea is totally correct.

However, since my 'LIST 1' is a variable list coming from more then one XLS, I can't set them.

What I tried to use is creating 2 Variables like these:

(vALL_OPT For ALL OPTIONALS)

=Chr(39)&Replace(GetFieldSelections([ALL OPTIONALS],',', GetSelectedCount([ALL OPTIONALS])), ',' , chr(39)&','&chr(39)) &chr(39)

(vPRE_OPT For PRE-SELECTED)

=Chr(39)&Replace(GetFieldSelections([OPTIONALS PRE-SELECTED],',', GetSelectedCount([OPTIONALS PRE-SELECTED])), ',' , chr(39)&','&chr(39)) &chr(39)

And adding this to a List Expression:

=ValueList($(vPRE_OPT),$(vALL_OPT))

So the List changes as the Optionals are selected (I mean, in real time), that's what I need mostly!

However, my Expression or Variable is wrong because with this Expression, I'm Adding the values of 2 lists into one, and I need 1 to add and 1 to remove, as I explained.

It's a little bit hard to understand i confess, if you need something, let me know please! I do need to get this working!

Thank you so much!

Not applicable
Author

Ok, well I did not thought of your approach. This looks great to me.

To resolve it, you can use below expression for vPre_OPT variable

=replace(chr(39)&Concat({1-$}[OPTIONALS PRE-SELECTED], ',') &chr(39),',',chr(39)&','&chr(39))

And then =ValueList($(vPRE_OPT),$(vALL_OPT))

Thanks,

Angad

Not applicable
Author

Thank you so much.