2 Replies Latest reply: Mar 16, 2017 12:14 PM by Virilo Tejedor RSS

    Can't use a constant on IF stement on a load script

    Virilo Tejedor

      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