Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
jlbenoit
Contributor
Contributor

Translation issue in if-statement

Hi,

I've a problem with translation in if-statement.

When i enter the field expression in a pie-chart

=if(metier='G',Only({<CODE={groupage}>} [$(=langue)]),if(metier='L','Logistique','Affretement')) 

i've got a dimension error.

When i create a variable

groupage  with expression =Only({<CODE={groupage}>} [$(=langue)])

and then enter the expression with the variable in the pie-chart


=if(metier='G',groupage,if(metier='L','Logistique','Affretement')) 


It's working.   Why it doesn't work without variable, is there a problem with the = sign ?



6 Replies
sunny_talwar

Wait what is a dimension and what is an expression? I am confused

devarasu07
Master II
Master II

Hi,

Can you share mock data and expected output? and also u can try below way

=if(metier='G',Only({<CODE={groupage}>} $(langue)),if(metier='L','Logistique','Affretement'))

or

=if(metier='G' and CODE='groupage', $(langue)),if(metier='L','Logistique','Affretement'))

jlbenoit
Contributor
Contributor
Author

The function (fx) Only({<CODE={groupage}>} [$(=langue)])  is the traduction of the code groupage in the users language.

If i put this function in a variable and then use as function in dimension field of chart  i've no problem.

like this where groupage is the variable

Sans titre2.png

=if(metier='G',groupage,if(metier='L','Logistique','Affretement'))      -> works fine



But if i put the function for the traduction directly, without passing by a variable like this

=if(metier='G',Only({<CODE={groupage}>} $(langue)),if(metier='L','Logistique','Affretement'))  -> get error


i've got a message

Sans titre.png

Is there any solution without using variables ?

sunny_talwar

May be wrap your Only function within a dollar sign expansion or add a TOTAL Qualifier

=If(metier = 'G', $(=Only({<CODE={groupage}>} [$(=langue)])), If(metier = 'L', 'Logistique', 'Affretement'))

or this

=If(metier = 'G', Only(TOTAL {<CODE={groupage}>} [$(=langue)]), If(metier = 'L', 'Logistique', 'Affretement'))

jlbenoit
Contributor
Contributor
Author

I've already tried, neither of these work.  

I think, there is a problem with the = sign  to assign the value of the translation.

sunny_talwar

Would you be able to share a sample?