Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Qlikview expression Year field name

Hi Team

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.

=if(Year<=Year(today()),1,0)

ie. 2015<=2017 it should give output as 1, but it is giving 0.


When I use a variable instead of Year Field.ie

a=Year

And replace the expression by:

=if($(a)<=Year(today()),1,0)

Then it is working.

So, is it because we have predefined Year function name?

Is there any other way to do this?

Please suggest.

Thanks in Advance

8 Replies
Anil_Babu_Samineni

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..

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
its_anandrjs

Write this in the variable with Max key word

=if( Max(Year) <= Year(today()),1,0)

its_anandrjs

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);

nehasaxena
Creator II
Creator II

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.

BR,

Neha

Anonymous
Not applicable
Author

Not working

its_anandrjs

Are your sure it is working at my end can you share sample file.

Anil_Babu_Samineni

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 ..

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
its_anandrjs

Check the attached sample app