I have a set of data that I want to create new columns in a repeated way.
for example,
column name: name_201203
values: 201203
column name: name_201206
values: 201206
Is there a way to create such a loop that creates all the columns needed?
Another way if possible to put a table that has the column names and values the then create them as the below table.
One more question, how about if the formula depends on other columns?
for example, instead of just formula as 201203
the value of the formula is:
when “date” <= 201203 then “sales_amount” else null
and the formula for column 201206 would be
when “date” <= 201206 then “sales_amount” else null
The issue is that I want the result to be the same as the column expressions that I created. The output data should have the same number of rows as the original data.