Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Merge values of two fields in one Listbox

Hi Community,

I am trying to create a listbox with values from two different fields.

I have Field 1 (possible values 'HB' or null() ) and Field 2 (possible values 'MW' or null() ).

These are all possible combinations of these values:

1. HB & null()

2. HB & MW

3. null() & MW

4. null() & null()

My intention is a checkbox with:

HB

MW

null() (called Rest)

When I am selecting HB I want all the data connect to HB and HB& MW, because HB& MW is a subset of HB. Same when selecting MW.

I attached some sample data where I already created the desired listbox with combining the fields in script and an expression in my listbox.

But the second part of the if-condition is not working.

Thanks in advance for your help!

Best regards

Niklas

2 Replies
stigchel
Partner - Master
Partner - Master

With the if's the HBMW value is never assigned to MW (at that point the first if already returned true).

In the load script you can use a crosstable to do that:

Inline:

LOAD * INLINE [

    Index,Field 1, Field 2

    1,HB,0

    2,HB,0

    3,HB, MW

    4,0, MW

    5,0, MW

    6,0,0

    7,0,0

    8,0,0

    9,0,0

    10,0,0

];

CrossTable(Sel,Combined_Field,1) Load

Index

,If(PurgeChar([Field 1]&[Field 2],0)='HB','HB') as HB

,If(PurgeChar([Field 1]&[Field 2],0)='MW','MW') as MW

,If(PurgeChar([Field 1]&[Field 2],0)='HBMW','HBMW') as HB

,If(PurgeChar([Field 1]&[Field 2],0)='HBMW','HBMW') as MW

,if([Field 1]&[Field 2]='00','Rest') as Rest

Resident Inline;

Drop table Inline

Also attached

rospigliosi
Creator
Creator

Hi Niklas,

the crosstable solution is absolutely the best solution,

an alternative would be to do 3 separate listboxes:

=If(Combined_Field = 'HB' or Combined_Field = 'HBMW', 'HB')

=If(Combined_Field = 'MW' or Combined_Field = 'HBMW', 'MW')

=If(len(Combined_Field )=0,'Rest')

Cheers