Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Moving chart expression to the script

I have the following expression in a straight table in my QV application:

IF(InsID1='SP' OR isnull(InsID1) and
isnull(InsID2) and
isnull(InsID3) and
isnull(InsID4) and
isnull(InsID5
),'Uninsured','Insured')

It works fine as an expression in the chart, but I want to move this to the script, creating a new field called InsuranceStatus, that would have a value of either Insured or Uninsured.  So far, my attempts to include this in the script have failed.  It's probably a syntax thing. 

Can anyone offer some ideas?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Yes, you will need to make something like

IF(InsID1='SP' OR (isnull(InsID1) and isnull(InsID2) and isnull(InsID3) and isnull(InsID4) and isnull(InsID5)),'Uninsured','Insured') as InsuranceStatus,


I've forgot to put that on the "if".


Regards,

Gabriel

View solution in original post

5 Replies
Anonymous
Not applicable
Author

Can you paste in the load statement script you have so far ?

Anonymous
Not applicable
Author

Hi!

Are you finding script errors, or the if doesn't shows the result that you're expecting? Maybe will need to include some parentheses on that if expression.

IF(InsID1='SP' OR (isnull(InsID1) and isnull(InsID2) and isnull(InsID3) and isnull(InsID4) and isnull(InsID5)),'Uninsured','Insured')

Regards,

Gabriel

Not applicable
Author

Hi, Gabriel.

I tried the same thing, but the script does not like the comma before "Uninsured'.  I think I'd need to add something like "AS InsuranceStatus" in there somewhere to create and populate the new field.

Bill, the script is long and complicated, and would probably detract from the conversation on this particular issue.

Anonymous
Not applicable
Author

Yes, you will need to make something like

IF(InsID1='SP' OR (isnull(InsID1) and isnull(InsID2) and isnull(InsID3) and isnull(InsID4) and isnull(InsID5)),'Uninsured','Insured') as InsuranceStatus,


I've forgot to put that on the "if".


Regards,

Gabriel

Not applicable
Author

Thanks, Gabriel.  That worked perfectly!  I'm not sure what I missed, but you found it.