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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Switch and Load

Hello,

Below I put some code.

-----

faktuurkop_main:
join LOAD
no_ordernr as Verkooporder,
no_forcod as Formule,
left('0' & no_refnr,3) as BronMain,

----

I would like to use the switch to give the field no_forcod a specific value depending on the loaded value.

f.e. if no_forcod = 2 then it should be loaded as a.

if no_forcod = 3 then is it should be loaded as b

if no_forcod = 4 then it should be loaded as c

a.s.o.

But I don't know how to solve this.

Maybe someone can help me.

Thanks in advance.

greinier

4 Replies
Not applicable
Author

Create an Excel File with two fields as no_forcod and Formule.

Fill the Data with Values

1,a

2,b

a.s.o

Import this excel file into QlikView connecting no_forcod field.

Anonymous
Not applicable
Author

But can this be solved by the switch statement. Or is that not possible ?

johnw
Champion III
Champion III

This:

if(no_forcod= 2,'a'
,if(no_forcod= 3,'b'
,if(no_forcod= 4,'c'
...
,if(no_forcod=27,'z'
,'other')))...) as Formule

Or this:

pick(match(no_forcod,2,3,4...27) + 1,'other','a','b','c'...'z') as Formule

Or this:

if(no_forcod>=2 and no_forcod<=27,mid('abcdefghijklmnopqrstuvwxyz',no_forcod - 1,1),'other') as Formule

Or this:

if(no_forcod>=2 and no_forcod<=27,chr(ord('a') + no_forcod - 2),'other') as Formule

Or this:

maxstring(mid('abcdefghijklmnopqrstuvwxyz',no_forcod - 1,1),'other') as Formule

Lots of ways to do things in the expression. Other ways to do it with mapping loads, another table, or whatever if the real problem is more complicated than the one presented.

Anonymous
Not applicable
Author

thx John, this is the information I needed.

Kind regards,

Greinier