Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

lavrendis
New Contributor

If statement in script

Hi there,

i would like to replace some of the values in one of my tables when i load the script with an if statement.

It seems that my syntax is not correct. I want to replace France with FR.

The field i am loading is [CountryregionID]

If it does not find France it should load the rest of values as is.

Best regards,

Lawrence

Tags (1)
1 Solution

Accepted Solutions
d_prashanthredd
Contributor III

Re: If statement in script

Hi Lawrence,

Load

     Fields1, Field 2, ... if( Upper(CountryregionID) = 'FRANCE', 'FR', CountryregionID ) as CountryregionID,

Field N, .... ;

Upper(CountryregionID) comparison will be taken care of france, France, FRANCE

Thanks,

Prashanth Reddy D.

5 Replies
d_prashanthredd
Contributor III

Re: If statement in script

Hi Lawrence,

Load

     Fields1, Field 2, ... if( Upper(CountryregionID) = 'FRANCE', 'FR', CountryregionID ) as CountryregionID,

Field N, .... ;

Upper(CountryregionID) comparison will be taken care of france, France, FRANCE

Thanks,

Prashanth Reddy D.

sadasiva
Contributor

Re: If statement in script

Hi Lawrence,

How do I replace/change values under a column while loading data?

This may helps.

Regards,

Sadasiva

MVP
MVP

Re: If statement in script

Or

...

If(CountryregionID Like 'FRANCE', 'FR', CountryregionID) as CountryregionID,

...

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
lavrendis
New Contributor

Re: If statement in script

Thank you for your replies.

I have a question regarding the country names. In my data the names  are in french and i have a KML file with the ISO2 code. If i need to translate all the country data i will need almost 200 consequent if statements. Is there a fastest way to do this?

Best regards,

Lawrence

d_prashanthredd
Contributor III

Re: If statement in script

I'm assuming that your country names are of length greater than 2 and ISO

coded are of length 2. In such case, you can write as..

If(Len(Countryname)>2, ISOCode, Countryname)

Slightly you can alter as per your lengths.

On Aug 10, 2017 20:43, "Lawrence Tzigersizoglou" <qcwebmaster@qlikview.com>

Community Browser