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: 
Not applicable

Conditionally load table with different parameters in where clause

Hi All,

I would need to conditional load same table with different parameters depending on vPriceType variable's value

i.e.

Let vPriceType = Pick(Input('Would you please choose Price Type','Caption'),'Distri','Street');

IF '$(vPriceType)' = Distri

Load:

AllPrices:

LOAD ID, 

     Country, 

     Source, 

     Price, 

     Date(Date) AS Date

FROM

AllPrices.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq)

Where Country = 'UK';

Elseif '$(vPriceType)' = Street

Load:

AllPrices:

LOAD ID, 

     Country, 

     Source, 

     Price, 

     Date(Date) AS Date

FROM

AllPrices.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq)

Where Country = 'DE';

Else Let vPriceType = Pick(Input('Would you please choose Price Type','Caption'),'Distri','Street');

Thanks in advance for your help.

Amko

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Perhaps like this:


Switch '$(vPriceType)'

Case 'Distri'

    SET vCountry = 'UK';

Case 'Street'

    SET vCountry = 'DE';

Case '...something else...'

    SET vCountry = '...whatever...';

Default

    SET vCountry = '...a default fallback value...';

End Switch

AllPrices: 

LOAD ID,   

    Country,   

    Source,   

    Price,   

    Date(Date) AS Date 

FROM 

AllPrices.csv 

(txt, codepage is 1252, embedded labels, delimiter is ',', msq) 

Where Country = '$(vCountry)';


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

Perhaps like this:


Switch '$(vPriceType)'

Case 'Distri'

    SET vCountry = 'UK';

Case 'Street'

    SET vCountry = 'DE';

Case '...something else...'

    SET vCountry = '...whatever...';

Default

    SET vCountry = '...a default fallback value...';

End Switch

AllPrices: 

LOAD ID,   

    Country,   

    Source,   

    Price,   

    Date(Date) AS Date 

FROM 

AllPrices.csv 

(txt, codepage is 1252, embedded labels, delimiter is ',', msq) 

Where Country = '$(vCountry)';


talk is cheap, supply exceeds demand
maxgro
MVP
MVP

LOAD ID,  

    Country,  

    Source,  

    Price,  

    Date(Date) AS Date

FROM

     AllPrices.csv

     (txt, codepage is 1252, embedded labels, delimiter is ',', msq)

where

  Country = pick(wildmatch('$(vPriceType)', 'Distri','Street'), 'UK', 'DE')

  ;

Not applicable
Author

Thank you Gysbert

Not applicable
Author

Grazie Massimo