1 Reply Latest reply: Oct 21, 2016 7:04 AM by Marcus Sommer RSS

    use variable as function dynamically

    Yves Ndjoli

      I have a set of variable

      var1= $1+1;

      var2=$1+2;

      var3=$1+3;

       

      my table

      A

      Var_Index

      Value

      X

      1

      10

      Y

      2

      100

      Z

      3

      1000

       

      I like to create a NewColumn that depends from the columns ‘Var_Index’ and ‘Value’

      For example, the first line Var_Index=1, Value=10 then NewColumn=$(var1(10))=10+1=11

      A

      Var_Index

      Value

      NewColumn

      X

      1

      10

      11

      Y

      2

      100

      102

      Z

      3

      1000

      1003

       

      Load

                  A,

                  Value,

                  $(var& Var_Index(Value)) as NewColumn

      Resident Table;

       

      My code doesn’t work, how can I modify it that it works.

      I try to avoid pick(Var_Index,…) and  If(Var_Index=….) because my list of variable is longer than this sample and I create the variable dynamically.

       

      Thanks for your help and answer.

       

      Nice Week End!