5 Replies Latest reply: Sep 19, 2014 9:45 AM by marc carreras RSS

    Edit Field Contents

      Hi All,

       

      Is it possible to edit the contents of a field one cell at a time via an if-then in Qlikview script? Lets say I have the field 'ApplicantName' and 'ApplicantID'. Because of coding issues, some of the ApplicantIDs are incorrect and need to be manually fixed. What I'd like to be able to do, for now at least, is have a function similar to:

       

      IF (ApplicantName = 'John Smith',222333) AS ApplicantID

       

      but have it replace the value in the field rather than try to write a new one. If I try to run that as is, it gives me an error stating 'Field names must be unique within table'. Any advice?

       

      Thanks!

      -Mike

        • Re: Edit Field Contents
          marc carreras

          Hi Michael,

           

          In case of a few mistakes in codind, try:

           

          load *, IF (ApplicantName = 'John Smith',222333, ApplicantID) AS ApplicantID_ok   //(extend the IFs conditions as needed)

          resident tableorigin;

           

          drop field ApplicantID;

          rename field ApplicantID_ok to ApplicantID;

          • Re: Edit Field Contents
            Gysbert Wassenaar

            Try this:

             

            IF(ApplicantName = 'John Smith',222333,ApplicantID) AS ApplicantID


            Note, you cannot create the field ApplicantID twice in a table, so this will not work:


            LOAD

                 ApplicantID,

                 ApplicantName,

                 IF(ApplicantName = 'John Smith',222333,ApplicantID) AS ApplicantID

            FROM ....


            It will fail because you're trying to create two fields with the same name in a table. That will also happen if you use the * (star) character to load all fields from the source.