Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Please help me with the error below.

  I am getting an error with the below if statement.

if(DEP_ACCT_OPN_DT >= $(CurrentMonth) and DEP_ACCT_OPN_DT <= $(PreviousMonth)) as FirstMonth,

Note :CurrentMonth is a variable with value set as

date(floor(monthstart(Today()))) .

Many Thanks

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion


if(DEP_ACCT_OPN_DT >= Date(floor(monthstart(Today()))) and DEP_ACCT_OPN_DT <= Date(floor(MonthEnd(Today()))), DEP_ACCT_OPN_DT ) as FirstMonth,

View solution in original post

11 Replies
rajeshvaswani77
Specialist III
Specialist III

Hi Abhi,

Your if condition is not correct.

Syntax is

If(Expression, return value if condition satisfied, return value if condition not satusfied)

You have an expression but you are not returning anything, the 2nd parameter, the 3rd parameter is optional.

thanks,

Rajesh Vaswani

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

I guess you trying to get date if both the condition is satisfied

try this

if(DEP_ACCT_OPN_DT >= $(CurrentMonth) and DEP_ACCT_OPN_DT <= $(PreviousMonth), DEP_ACCT_OPN_DT ) as FirstMonth,


Hope it helps

MayilVahanan

Hi

Try like this

if(DEP_ACCT_OPN_DT >= $(CurrentMonth) and DEP_ACCT_OPN_DT <= $(PreviousMonth),DEP_ACCT_OPN_DT ) as FirstMonth

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Thank very much for your help but I am getting the error again .

Error in expression:

')' expected

LOAD

    

     DEP_ACCT_NBR,

           

  

        if(DEP_ACCT_OPN_DT >= =date(floor(monthstart(Today()))) and DEP_ACCT_OPN_DT <= =date(floor(MonthEnd(Today()))), DEP_ACCT_OPN_DT ) as FirstMonth,

   

     DEP_ACT_AGE_DD,

         

FROM

(biff, embedded labels, table is [Sheet1$])

MayilVahanan

HI

Try like this

If(DEP_ACCT_OPN_DT >= date(floor(monthstart(Today()))) and DEP_ACCT_OPN_DT <= date(floor(MonthEnd(Today()))), DEP_ACCT_OPN_DT ) as FirstMonth

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
CELAMBARASAN
Partner - Champion
Partner - Champion


if(DEP_ACCT_OPN_DT >= Date(floor(monthstart(Today()))) and DEP_ACCT_OPN_DT <= Date(floor(MonthEnd(Today()))), DEP_ACCT_OPN_DT ) as FirstMonth,

Not applicable
Author

Yup,I got the date which i wanted.But I wanted to use a variable istead of the date function in the script.Can u please tell me why is it giving error when I am using variable here.

Thanks again.

Not applicable
Author

  Can you please help me with the below if condition.Sorry to bug you.Many thanks for all your help.I appreciate it.

(if(DEP_ACCT_OPN_DT >= Date(floor(monthstart(Today()))) and DEP_ACCT_OPN_DT <= Date(floor(MonthEnd(Today()))), DEP_ACCT_OPN_DT ), 'CurrentMonth',

(if(DEP_ACCT_OPN_DT >= Date(floor(monthstart(Today(),-1))) and DEP_ACCT_OPN_DT <= Date(floor(MonthEnd(Today(),-1))), DEP_ACCT_OPN_DT ) ,'PreviousMonth',

( if(DEP_ACCT_OPN_DT >= Date(floor(monthstart(Today(),-2))) and DEP_ACCT_OPN_DT <= Date(floor(MonthEnd(Today(),-2))), DEP_ACCT_OPN_DT ) , 'PREPreviousMonth'))) as Bucket,

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

How you assigned it to a variable?

Variable Assignment should be

SET CurrentMonth= Date(floor(monthstart(Today())));