Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
etrotter
Creator II
Creator II

If statement with multiple languages

I am creating an app that has three languages in it. the languages were created by having a table with three versions of the data in each language and there being filters you can set to pick the language. That being said I want to have a table conditionally colored but I am having issues integrating the languages.

this is the origional if statement without the addition of the other languages:

if(Source='Forestry' and (Geography<>'Brazil' xor ForestryScenario='Globiom FC'),green(), red())

here is the addition of the new languages but it is not working

if((Source='Forestry' OR '森林业' OR 'Silvicultura') and ((Geography<>'Brazil' OR 'Brasil' OR '巴西') xor ForestryScenario='Globiom FC'),green(), red())

the goal is that forestry is green unless it is Brazil. I do want it to be green for Brazil if Globiom is selected though! Globiom FC is the same in every language.

Thanks in advance!

1 Solution

Accepted Solutions
etrotter
Creator II
Creator II
Author

I used a match function so Match(Source, 'Forestry', 'Silvacultura', '森林业')  and it worked!

View solution in original post

7 Replies
ogster1974
Partner - Master II
Partner - Master II

I think if you identify the language first then put your language based conditions in you will have better luck.

When making reference data local you usually have a key value to Id it regardless of the language.   perhaps you can base the condition on the key value rather than the local values as you will struggle supporting it if you need to add more languages later.

etrotter
Creator II
Creator II
Author

So something like this?

If((Lang='en'),if(Source='Forestry' and (Geography<>'Brazil' xor ForestryScenario='Globiom FC'),green(), red()),

if(Lang='ch',IF(Source='森林业' and (Geography<>'巴西' xor ForestryScenario='Globiom FC'),green(), red())),

IF(Source='Silvicultura' and (Geography<>'Brasil' xor ForestryScenario='Globiom FC'),green(), red()))

petter
Partner - Champion III
Partner - Champion III

Since Forestry, 森林业 and Silvicultura means the same and are related by being in the same table on the same row you can just check on either of them - not all of them:


If( Source='Forestry' AND Geography<>'Brazil' OR ForestryScenario='Globiom FC') , green() , red() )

JustinDallas
Specialist III
Specialist III

Do you mind telling us the source of this data?  If it;s coming from an ERP/CRM of some sort, then there should be a catalog/dictionary available to you that you can pull down.  If you are making this yallselves, then I might suggest putting the data in a Dictionary type table, and then going from there.

Using a dictionary, it would allow you to pick a Base Language, and you could write your scripts according to that.  Better yet, you could create Codes for all your dictionary entries and then use that, for instance

if((Source='Forestry' OR '森林业' OR 'Silvicultura') and ((Geography<>'Brazil' OR 'Brasil' OR '巴西') xor ForestryScenario='Globiom FC'),green(), red())

Would become

if(( SourceBaseId='FORESTRY_CODE' ) and ((Geography<>'BRAZIL_CODE' ) xor ForestryScenario='Globiom FC'),green(), red())

Your dictionary table would look something like this

Dict:

  DictCode,  => FORESTRY_CODE, BRAZIL_CODE

  BaseLanguageText, => Brazil

  ChineseText, => 巴西

  EnglishText, => Brazil

  PortugueseText => Brasil

And then you would left join all the fields where you needed the translation.  The drawback is that you would have to rename your Dict fields to avoid inadvertent keys.  Also, this could require a lot of work, and might be unworkable as I've seen one Catalog out of hundreds have over 5000 values spread over 17 languages.

petter
Partner - Champion III
Partner - Champion III

This is an example showing how you can let Qlik's Associative Model work for you dynamically and pick the right language:

(I have attached the Qlik Sense App)

2017-12-08 21_16_10-Qlik Sense Desktop.png

2017-12-08 21_15_38-Qlik Sense Desktop.png

petter
Partner - Champion III
Partner - Champion III

Actually this is a better approach that is still using the associative model but simpler to understand. Have attached a revised app.

etrotter
Creator II
Creator II
Author

I used a match function so Match(Source, 'Forestry', 'Silvacultura', '森林业')  and it worked!