5 Replies Latest reply: Jun 1, 2018 2:08 PM by David Rudd RSS

    How to perform an operation on all columns

    David Rudd

      I have the following script that converts null values to zeros in the load editor. However, I don't know how many columns I might have in a future file. Is there any way to create some type of loop to perform this on all columns.

       

      Table1:

      Load

      "Plant",

      if(IsNull("01/2018"),0, "01/2018") AS "01/2018",

      if(IsNull("02/2018"),0, "02/2018") AS "02/2018",

      if(IsNull("03/2018"),0, "03/2018") AS "03/2018",

      if(IsNull("04/2018"),0, "04/2018") AS "04/2018",

      if(IsNull("05/2018"),0, "05/2018") AS "05/2018",

      if(IsNull("06/2018"),0, "06/2018") AS "06/2018",

      if(IsNull("07/2018"),0, "07/2018") AS "07/2018",

      if(IsNull("08/2018"),0, "08/2018") AS "08/2018",

      if(IsNull("09/2018"),0, "09/2018") AS "09/2018",

      if(IsNull("10/2018"),0, "10/2018") AS "10/2018",

      if(IsNull("11/2018"),0, "11/2018") AS "11/2018",

      if(IsNull("12/2018"),0, "12/2018") AS "12/2018",

      if(IsNull("13/2018"),0, "13/2018") AS "13/2018"

      Source;

       

      Maybe something like:

       

      LET col_count = NoOfFields('Table1');


      LOAD

      FOR i=0 to $(col_count)


           if(IsNull(i),0, i) AS i


      NEXT i