Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

How to state "not equal to current month" under script

Hi,

I am not sure how to state "not equal to current month" under script

NinthStats2:    //Table name

NoConcatenate Load

    ...

    ...

    ninth_LastRead_MY          //format is 'MMM-YYYY', e.g. Jan 2015, Feb 2015...

    if(month(ninth_LastRead_MY)<>month(today()),'Inactive','Active') as ninth_activity

Resident NinthStats1;

Drop Table NinthStats1;

The error I got:

As I want to create a column (ninth_activity) that is either Inactive or active.

So if month(ninth_LastRead_MY) is not equal to month(today()) which is Nov, it will be inactive, otherwise active.

Thank you!

Update: I miss out a (,) before 'if', problem solved

2 Replies
sinanozdemir
Valued Contributor III

Re: How to state "not equal to current month" under script

Since you said that your date format is MMM-YYYY, then you can try this:

if(Date(Date#(ninth_LastRead_MY, 'MMM YYYY'), 'MMM')<>month(today()),'Inactive','Active') as ninth_activity

What you are doing is that you are telling Qlik that your date field is formatted in 'MMM YYYY' with Date#() and then getting the month portion of it with Date() function.

Hope this helps.

Not applicable

Re: How to state "not equal to current month" under script

sinanozdemir

Thank you! I noticed that the reason it don't work is because I miss out a (,) before 'if' in the previous sentence. Nevertheless, I learn something new from your post. Thank you