Conditionally load table with different parameters in where clause

IF '$(vPriceType)' = Distri then Load table Where Country = 'UK';
IF '$(vPriceType)' = Street then Load table Where Country = 'DE';
How to load dynamically?

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)';

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')  ;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.