Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'd like to load data from a database, and create a new field RESULT based on this condition:
- If STATUS is 3, RESULT contains value of "ERROR_DESCRIPTION" for this row
- Else, RESULT cotains the constant value "Ok."
The following code produces an error during the data load, because QlikSense expects "Ok." to be a column name.
LOAD ID as ID_REQUEST,
.. // lots of columns
ERROR_DESCRIPTION,
STATUS,
If(STATUS = 3, "STATUS", "OK.") as RESULT;
SQL SELECT ID,
"ID",
"REQUEST_DATE",
...
ERROR_DESCRIPTION,
STATUS,
FROM MYDB.REQUESTS;
I tryed the next alternatives, without success:
- If(STATUS = 3, "STATUS", Text("OK.")) as RESULT;
- let vOkMessage = "Ok.";
If(STATUS = 3, "STATUS", $(vOkMessage)) as RESULT;
- If(STATUS = 3, "STATUS", "OK_MESSAGE") as RESULT;
SQL SELECT ID,
"Ok." as "OK_MESSAGE",
...
FROM MYDB.REQUESTS;
How could I choose between a column value or a constant depending on "STATUS"?
Thanks in advance.
Best regards,
Virilo
Try with single quotes around the constant instead of double quotes
LOAD ID as ID_REQUEST,
.. // lots of columns
ERROR_DESCRIPTION,
STATUS,
If(STATUS = 3, "STATUS", 'OK.') as RESULT;
SQL SELECT ID,
"ID",
"REQUEST_DATE",
...
ERROR_DESCRIPTION,
STATUS,
FROM MYDB.REQUESTS;
Try with single quotes around the constant instead of double quotes
LOAD ID as ID_REQUEST,
.. // lots of columns
ERROR_DESCRIPTION,
STATUS,
If(STATUS = 3, "STATUS", 'OK.') as RESULT;
SQL SELECT ID,
"ID",
"REQUEST_DATE",
...
ERROR_DESCRIPTION,
STATUS,
FROM MYDB.REQUESTS;
Thanks a lot!