Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

gleybson_calyx
New Contributor III

Many if's

Hello people,

I need to create an index from a text field.

so I started doing it like this:

if (index (upper ("Text Neg"), 'GIN'), 'Drink'

if (index (upper ("Text Neg"), 'VODKA'), 'Drink'

if (index (upper ("Text Neg"), 'VODCA'), 'Drink', ...

The problem is that there are a lot of words and when it arrives in about 50 ifs it catches.

I'm using QlikSense nov2017.

Do you have any other solution for me not to use all these if's?

1 Solution

Accepted Solutions

Re: Many if's

I think you misplaced on parenthesis

Pick(

    WildMatch("Text Neg",

        '*GIN*', '*VODKA*', '*VODCA*'), 'Drink', 'Drink', 'Drink') as Indice,

6 Replies

Re: Many if's

May be with Pick(WildMatch())

Pick(WildMatch([Text Neg], '*GIN*', '*VODKA*', '*VODCA*', ...), 'Drink', 'Drink', 'Drink', ....) ....

gleybson_calyx
New Contributor III

Re: Many if's

I applied that way.

I think I made a mistake.

Pick(

    WildMatch("Text Neg",

        '*GIN*', '*VODKA*', '*VODCA*', 'Drink', 'Drink', 'Drink')) as Indice,

Re: Many if's

I think you misplaced on parenthesis

Pick(

    WildMatch("Text Neg",

        '*GIN*', '*VODKA*', '*VODCA*'), 'Drink', 'Drink', 'Drink') as Indice,

Re: Many if's

I see that I missed that in my response also.... fixed my response also

gleybson_calyx
New Contributor III

Re: Many if's

Perfect friend.

It worked. Just one more thing.

for every word I put in "WildMatch" do I have to repaint it in "Pick"?

Example below.

Pick(

    WildMatch("Text Neg",

        'GIN',         'VODKA',         'VODCA',        'VÓDCA',        'VÓDKA',

        'VODIKA',      'VÓDICA',        'VÓDIKA',       'GIM',        'CONHAQUE',

        'COMIDA',        'BOLO',        'BOLINHO',        'COMIDA DE PRIMEIRA'

       

        ), 'Drink', 'Drink', 'Drink', 'Drink', 'Drink', 'Drink', 'Drink', 'Drink', 'Drink', 'Drink',

        'Comida', 'Comida', 'Comida', 'Comida') as Indice,

Re: Many if's

Yes, or you can do something like this

If(WildMatch("Text Neg",

        'GIN',        'VODKA',        'VODCA',        'VÓDCA',        'VÓDKA',

        'VODIKA',      'VÓDICA',        'VÓDIKA',      'GIM',        'CONHAQUE'), 'Drink', 'Comida') as Indice

or this

If(WildMatch("Text Neg",

        'GIN',        'VODKA',        'VODCA',        'VÓDCA',        'VÓDKA',

        'VODIKA',      'VÓDICA',        'VÓDIKA',      'GIM',        'CONHAQUE'), 'Drink',

If(WildMatch("Text Neg",

        'COMIDA',        'BOLO',        'BOLINHO',        'COMIDA DE PRIMEIRA'),

'Comida') as Indice

But if you do use Pick, then you will have to repeat Drink for all the matches you make

Community Browser