Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello.
I am new to Qlik and have a very easy question. In my data I have a column with this values:
Default
Chinese
Spanish
Online
Warehouse
Store
During the load of the app, I need to change all but "Chinese" and "Spanish" into "English". I have 4 REPLACES at this moment that are doing the job, but I know that this is not the optimal.
REPLACE(REPLACE(REPLACE(REPLACE(column1, 'Default', 'English'), 'Online','English'),'Warehouse','English'),'Store','English') as language
How can I optimize this with ELSE to get it ready if we need to add more values?
Thanks!!
Here's how you can do it with an if().
if(Match(column1, 'Chinese', 'Spanish'), column1, 'English') as column1
-Rob
Edit note: Typo corrected.
G'day @Shaglok,
The applymap() function is great for more complex scenarios but Rob's solution is better for this one, however he has a typo. It should read ...
if( Match(column1, 'Chinese', 'Spanish') > 0, column1, 'English') as column1
Although it's not strictly necessary, I always include "> 0" as the Match() function returns an integer and not a boolean value.
Cheers, Barnaby.