Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Switch Statement

Hi Guys,

Please I am trying to write a Switch Case Statement but I can figure it out.

For example I want to write a switch case statement instead of this "if" statement below:

if(max(Gas) < 25/10 , 'G1.6',

if(max(Gas) < 40/10 , 'G2.5')) and so on ...

I have attached the sample data source.

Thanks

2 Replies
swuehl
MVP
MVP

Unfortunately, there is no switch case conditional statement for use in a LOAD statement (there is one for use as a script excecution control statement (but not within a LOAD)).

You can maybe use an INTERVALMATCH to achieve what you want:

INPUT:

LOAD Klasse,

     [Minimaal verbruik],

     [Nominaal verbruik],

     [Maximaal verbruik],

     Verbruiksklasse,

     Gas

FROM

[GasaansluitingenWiki.xlsx]

(ooxml, embedded labels, table is Blad1);

Intervals:

LOAD Klasse as GasClass,

     [Minimaal verbruik] as Start,

     Alt(Peek('Start')-1E-9, 1E9) as End

Resident INPUT Order by   [Minimaal verbruik] desc;

JOIN

IntervalMatch (Gas) LOAD Start,End Resident Intervals;

DROP TABLE INPUT;

Not applicable
Author

Maybe this works:

PICK ( WILDMATCH (Gas, <25/10, <40/10), 'G1.6','G2.5') AS xGas