Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Jayz1489
Contributor II
Contributor II

Error in IF statement

Hi,

I am working on a problem where every month I receive a report of all the  users and the date of their account creation. Now I want to show two things on the dashboard.

1. New users

2. Existing users

So whenever I receive a new report I add a new column "Report Date" with current month value in the excel sheet itself to compare new and existing users.

Now in the load script I am trying to add a new column with True/1 and False/0 values( any value to distinguish )so that I can use the value in  my dashboard. But I am receiving the error.

If(Year("Report Date")=Year("Creation Date") and Month("Report Date")=Month("Creation Date")"New", "Old")) As "IsNewUser"

I am getting the following error

The following error occurred:
Unexpected token: ',', expected one of: ')', 'OPERATOR_PLUS', 'OPERATOR_MINUS', 'OPERATOR_MULTIPLICATION', 'OPERATOR_DIVISION', 'OPERATOR_STRING_CONCAT', 'like', ...
The error occurred here:
If(Year("Report Date")=Year("Creation Date") and Month("Report Date")=Month("Creation Date")>>>>>>,<<<<<<"New", "Old")) As "IsNewUser"

 

Can some one please help figuring out the wrong or suggest some approach?

Thanks,

Jay

2 Solutions

Accepted Solutions
Digvijay_Singh

Looks weird, may be try 'New', 'Old' with single quotes. 

Can you share your script statements , few lines above and below the error statement, would like to give deeper look.

View solution in original post

Vegar
MVP
MVP

Are New and Old field names or are you trying to set string values?

 

By using " " you are using the field name, by using ' ' you are using the string value.

View solution in original post

8 Replies
Vegar
MVP
MVP

It looks like you have one end paranthesis to much in your expression. 

If(  Year("Report Date")=Year("Creation Date") and Month("Report Date")=Month("Creation Date"), "New",  "Old" )) As "IsNewUser"

Jayz1489
Contributor II
Contributor II
Author

Still the same error. Not sure why it is pointing towards the ,

 

 

The following error occurred:
Unexpected token: ',', expected one of: ')', 'OPERATOR_PLUS', 'OPERATOR_MINUS', 'OPERATOR_MULTIPLICATION', 'OPERATOR_DIVISION', 'OPERATOR_STRING_CONCAT', 'like', ...
The error occurred here:
If(Year("Report Date")=Year("Creation Date") and Month("Report Date")=Month("Creation Date")>>>>>>,<<<<<<"New", "Old") As "IsNewUser"
Vegar
MVP
MVP

I think it looks ok, but you could try to box your comparisons inside parentheses. Like this:

If(  (Year("Report Date")=Year("Creation Date")) and (Month("Report Date")=Month("Creation Date")), "New","Old" ) as "IsNewUser"

Jayz1489
Contributor II
Contributor II
Author

@Vegar : Its still the same, showing error in the comma:

 

If(  (Year("Report Date")=Year("Creation Date")) and (Month("Report Date")=Month("Creation Date")), "New","Old" ) as "IsNewUser"

Digvijay_Singh

Looks weird, may be try 'New', 'Old' with single quotes. 

Can you share your script statements , few lines above and below the error statement, would like to give deeper look.

Vegar
MVP
MVP

Are New and Old field names or are you trying to set string values?

 

By using " " you are using the field name, by using ' ' you are using the string value.

Jayz1489
Contributor II
Contributor II
Author

Thank you..this worked 🙂

Jayz1489
Contributor II
Contributor II
Author

Thank you..this worked 🙂

New thing learnt 🙂