I have a field name as "Year". It has only one value ie. 2015. When I am writing the below expression it is not giving me correct result.
ie. 2015<=2017 it should give output as 1, but it is giving 0.
When I use a variable instead of Year Field.ie
And replace the expression by:
Then it is working.
So, is it because we have predefined Year function name?
Is there any other way to do this?
Thanks in Advance
If you have really one Year then it should return one, If you have more than one it returns zero because Qlik can not identify from Year field to comparison. If you try same expression in straight table this works like charm but not in table box..
This i suggest for the variables another one is because what ever value you have in your field you have to find it and get selected on any variable or a max value or may be Getfieldselections(Year) but this works when you have select any value in the Year field.
Let a = Max(Year);
Let b= if( $(a) <= Year(Today()),1,0);
As Anil said, in the variable it is storing single value at a time that's why it is working properly but when you are directly using there must be more than 1 value for Year and thus not working.
You can't say direct without checking. This should work as expected. But the reason you are saying it's not working that means i believe you are doing some end BTA for others. So, We would like to offer you before not knowing anything until unless something guess ..