Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Case statement in Load Script

Hi,

i'm new to Qlikview, Is it possible to write a case statement in the Load script? i'm trying to write the below script and its giving syntax errors. can someone please help me in figuring out this.

CASE WHEN (Product ='Toys')

THEN ([Revenue]+[Tax]+[GP]) ELSE

([Revenue]) END TotalPrice

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try

LOAD

     IF( Product = 'Toys', [Revenue]+[Tax]+[GP], [Revenue]) as TotalPrice,

     ...

FROM ...;

View solution in original post

5 Replies
swuehl
MVP
MVP

Try

LOAD

     IF( Product = 'Toys', [Revenue]+[Tax]+[GP], [Revenue]) as TotalPrice,

     ...

FROM ...;

simondachstr
Luminary Alumni
Luminary Alumni

if(Product = 'Toys',

     [Revenue] + [Tax] + [GP],

     [Revenue]

     )                              AS TotalPrice

danieloberbilli
Specialist II
Specialist II

You can look up the conditional functions in help e.g. if then else. Or Sub...end sub if you need a loop to create fields/tables.

Maybe something like this works for you:

Load

if(Product = 'Toys',  [Revenue] + [Tax] + [GP], [Revenue]) as TotalPrice

resident / from...

jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hi,

I think the When statement, as well as Case are control structures for altering the behaviour of complete blocks of script (for example full tables).

What you describe can be done either with pick(match()) or if. Pick(match()) can be useful if you have several escenarios like

pick(match(Product, 'Toys','Fruits','Furniture'), Formula1, Formula2, Formula3) as Field

otherwise it would be better with an if

regards

Not applicable
Author

Thanks Everyone!!