Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
sharmasapna
New Contributor III

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

Tags (3)
8 Replies

Re: Qlikview expression Year field name

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

Re: Qlikview expression Year field name

Write this in the variable with Max key word

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

Re: Qlikview expression Year field name

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
Contributor II

Re: Qlikview expression Year field name

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

sharmasapna
New Contributor III

Re: Qlikview expression Year field name

Not working

Re: Qlikview expression Year field name

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

Re: Qlikview expression Year field name

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

Re: Qlikview expression Year field name

Check the attached sample app