Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Karim_Khan
Creator III
Creator III

can we use case statement

Hi Team,

  can we use case statement in script or Expression?

I have the two Sales Level 1 and Sales Level 2.

In Sales Level 1 I have Field EMEAR-REGION which is mapped to Sales Level 2 value i.e

EMEAR - CENTRAL

EMEAR - SOUTH

EMEAR - EMERGING

EMEAR - NORTH

EMEAR - UK


But in above Field If I select EMAR-REGION then it should directly associate to EMEAR - EMERGING

and I want to create one more Field with name EUROPE in Sales Level 2 which should directly pick the remaining 4 fields.


Regards,

KK !

KK
1 Solution

Accepted Solutions
gautik92
Specialist III
Specialist III

you cannot use or he has given two conditions yu can use mapping or you can use if condition

View solution in original post

12 Replies
Not applicable

Not quite clear with your requirement. As per what I understood, you can use Mapping Load/ApplyMap or nested if conditions. Though Maaping Load/ApplyMap is the recommended way.

/* Mapping Load */

DECODE:

Mapping LOAD * INLINE [

    SLS_LVL_2, SLS_LVL1

    EMEAR-EMERGING, EMEAR-REGION,

    EMEAR-CENTRAL, EUROPE

    EMEAR-SOUTH, EUROPE

    EMEAR-NORTH, EUROPE

    EMEAR-UKI, EUROPE

];

LOAD

     ApplyMap('DECODE',[Sales Level 2],[Sales Level 1]) as [Sales Level 1],

     [Sales Level 2],

     [Net Bookings]

FROM

File.xlsx

(ooxml, embedded labels, table is Sheet1);

(OR)

/*If Condition */

LOAD

     If([Sales Level 2]='EMEAR-EMERGING','EMEAR-REGION',

     If(Match([Sales Level 2],'EMEAR-CENTRAL','EMEAR-SOUTH','EMEAR-NORTH','EMEAR-UKI'),'EUROPE',[Sales Level 1])) as [Sales Level 1],

     [Sales Level 2],

     [Net Bookings]

FROM

File.xlsx

(ooxml, embedded labels, table is Sheet1);

Regards,

KKR

Karim_Khan
Creator III
Creator III
Author

HI Kranti,

    But while using (OR) condtion  i am unable to load the script

KK
gautik92
Specialist III
Specialist III

you cannot use or he has given two conditions yu can use mapping or you can use if condition

Karim_Khan
Creator III
Creator III
Author

Tnx.

KK
Karim_Khan
Creator III
Creator III
Author

Hi Gowatham,

  Now I got the data.Suppose if I want a specific condition like

LOAD

 

     If(Match([Sales Level 2],'EMEAR-CENTRAL','EMEAR-SOUTH','EMEAR-NORTH','EMEAR-UKI'),'EUROPE',[Sales Level 1])) as [Sales Level 1],

     [Sales Level 2],

     [Net Bookings]

this is working for IOT and when I select the IOE categgory then it should combine the data like below.

If(Match([Sales Level 2],'EMEAR-CENTRAL','EMEAR-SOUTH','EMEAR-NORTH','EMEAR-UKI','EMEAR -UNALLOCATTED',EMAE -OTHER),'EUROPE',[Sales Level 1])) as [Sales Level 1],

[Sales Level 2],

     [Net Bookings]

I want this specific condtion

KK
Digvijay_Singh

Use Noconcatenate before new script code, you might have dropped table at the end. Just guessing.

gautik92
Specialist III
Specialist III

use mapping load you ll get two different fields

Mapping1:

Mapping LOAD

     If(Match([Sales Level 2],'EMEAR-CENTRAL','EMEAR-SOUTH','EMEAR-NORTH','EMEAR-UKI'),'EUROPE',[Sales Level 1])) as [Sales Level 1],

     [Sales Level 2]

Mapping 2:

Mapping Load

If(Match([Sales Level 2],'EMEAR-CENTRAL','EMEAR-SOUTH','EMEAR-NORTH','EMEAR-UKI','EMEAR -UNALLOCATTED',EMAE -OTHER),'EUROPE',[Sales Level 1])) as [Sales Level 1],

[Sales Level 2]

first mapping you can use it for IOT and Second for IOE

Karim_Khan
Creator III
Creator III
Author

Can I apply this in one single  slot in my given script

Cisco:

LOAD [End Customer Global Ultimate Name],

     Country,

     [End Customer HQ Top],

    

   

     [Sales Level 3],

     [Sales Level 4],

     [Sales Level 5],

     [Partner Name],

     [Fiscal Period ID] as Fiscalid,

     [Net Bookings],

     CATEGORY ,

     If([Sales Level 2]='EMEAR-EMERGING','EMEAR-REGION',

     If(Match([Sales Level 2],'EMEAR-CENTRAL','EMEAR-SOUTH','EMEAR-NORTH','EMEAR-UKI') AND MATCH([Sales Level 2],'EMEAR-CENTRAL','EMEAR-SOUTH','EMEAR-NORTH','EMEAR-UKI','EMEA OTHER'),'EUROPE',[Sales Level 1]))  as [Sales Level 1],

     [Sales Level 2]

    

FROM

but its not working

KK
Digvijay_Singh

Check this one.