Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Case Statement

Hi guys,

I have a case statement

case

  when (territory = 'EXP FR' or territory like 'FRA%') then 'France'

  when territory = 'EXP IR' then 'Ireland'

  when territory in ('NIR WH','NWA WH','SCO WH','NOR WE','SWE WH','NOR EA','EMD WH','MAN WE','MAN EA','MID WH',

  'SEA SO','SEA WH','SWA WH','EAN WH','SCO WH') then 'UK'

  when territory = 'EXP WH' then 'ROW'

  when territory = 'EXP BE' then 'Belgium'

  when territory = 'EXP GE' then 'Germany'

  when territory = 'EXP CH' then 'Channel Islands' end as customer_country

I know this is a mixture of wildmatch and match, so is it possible to put this into a load script or is this best kept in a SQL statement?

Thanks

4 Replies
sorrakis01
Specialist
Specialist

Hi,

Case statement is not possible in LOAD script

Use ifs and Match function.

a little example:

LOAD

  If(territory = 'EXP FR','France',

  If(territory = 'EXP IR', 'Ireland',

  If(Match(territory,'NIR WH','NWA WH','SCO WH','NOR WE','SWE WH','NOR EA','EMD WH','MAN WE','MAN EA','MID WH','SEA SO','SEA WH','SWA WH','EAN WH','SCO WH')>0,'UK','ROW'))) AS territory;

LOAD * INLINE [

    territory

    EXP FR

    EXP IR

    NIR WH

];

Regards

PrashantSangle

Hi,

You can try with nested if -else.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
ogster1974
Partner - Master II
Partner - Master II

Perform the case statement in an SQL View and bring that across.

Or as you suggest use Pick and Wildmatch in the load.

Pick(WildMatch(territory, 'EXP FR', 'EXP IR', '*'),

     'France',

     'Ireland',

     'Other') AS  customer_country

Compare times to load the view verse doing it in script and take the quicker option.  Both will work.

Anonymous
Not applicable
Author

Cheers guys! I will just keep it in the SQL then I think..