Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
cancel
Showing results for 
Search instead for 
Did you mean: 
gleybson_calyx
Contributor III
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
sunny_talwar
MVP
MVP

I think you misplaced on parenthesis

Pick(

    WildMatch("Text Neg",

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

View solution in original post

6 Replies
sunny_talwar
MVP
MVP

May be with Pick(WildMatch())

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

gleybson_calyx
Contributor III
Contributor III
Author

I applied that way.

I think I made a mistake.

Pick(

    WildMatch("Text Neg",

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

sunny_talwar
MVP
MVP

I think you misplaced on parenthesis

Pick(

    WildMatch("Text Neg",

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

sunny_talwar
MVP
MVP

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

gleybson_calyx
Contributor III
Contributor III
Author

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,

sunny_talwar
MVP
MVP

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