Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Read about the latest Qlik Community enhancements on the Community News blog!
cancel
Showing results for 
Search instead for 
Did you mean: 
Bukan4x4
Contributor III
Contributor III

variable do not work

Hello all, this must be a  simple question for users more expertises than me ( almost all  🙂 ) .

Well, I have a graphic that show Sales by Months, I need to use a condition to set until which month the graphic shows the sales, this depend which year I have selected, the expression I used for the variables is:

If( [Year]<'2019',
'12',
'2' )
//for show 12 months or 2 months

but the grafphic don't work.  for other hand if I set manually the expression like:

='12'

or

='2'

The graphic is show fine. What is the problem ? how I can correct my expression for use the condition?

 

thanks for advance.

Jorge

 

 

1 Solution

Accepted Solutions
Bukan4x4
Contributor III
Contributor III
Author

Thanks all for the answers, finnaly a find my error, the problem isn't the uses of single quotes, the problem was the call of variable in my chart, I used this expression: "OrdenMes<=vMesActual" and work fine with one value but not with a expression, so the solution was change for: "OrdenMes<=$(vMesActual)" In now work fine!

View solution in original post

5 Replies
pradosh_thakur
Master II
Master II

If( [Year]<2019,
'12',
'2' )

Single quotes denotes a string and > and < can't be used with that . So i have removed the singlequotes from 2019 and it shall work fine.

Thanks

Pradosh

Learning never stops.
Claudiu_Anghelescu
Specialist
Specialist

Try in this way:


If( [Year]<2019, 12, 2)

 

The expression cannot compare a string with a number.

To help community find solutions, please don't forget to mark as correct.
rubenmarin

If it's a variable value maybe you need an starting equal sign to return the calculted value, and not the expression:
=If([Year]<2019, 12, 2)

This works if there is only one year selected, in case of many possible years [Year] will return null, an aggregation function can avoid that, in example:
=If(Max([Year])<2019, 12, 2)
Bukan4x4
Contributor III
Contributor III
Author

Thanks Ruben, but the expression "= if(..)" don't work,  I set the field year as "only one value" , so isn't not a problem tha multiple value.

Bukan4x4
Contributor III
Contributor III
Author

Thanks all for the answers, finnaly a find my error, the problem isn't the uses of single quotes, the problem was the call of variable in my chart, I used this expression: "OrdenMes<=vMesActual" and work fine with one value but not with a expression, so the solution was change for: "OrdenMes<=$(vMesActual)" In now work fine!

View solution in original post