Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: insert column dinamically

  1. #1
    Join Date
    Nov 2008

    Default insert column dinamically

    Hi everyone,
    I tried to insert a column with calculated field in a table dinamically.


    month year code
    1 2008 aaa
    9 2008 bbb

    I want this (in the same table):

    month year code period
    1 2008 aaa 1
    9 2008 bbb 2

    how can i get this?


  2. Default Not sure

    Hi Markinho,
    I'm not sure what exactly you want?

    Do you read those columns from a database (TableInput)?

    What is the calculation you want to perform? It is not obvious to me from the sample data?


  3. #3
    Join Date
    Nov 2008


    you're right.
    I read info from a table input.
    I want to add a column with the period of the year for each row i read, based on the month.

  4. #4


    You have curious periods/sample data.
    Month 1 => period 1
    Month 9 => period 2

    Is the period 6 or 8 month in length - or 3 as used in accounting?

    There are several ways to get the period.
    - Divide by 3 or 6 or 8
    - CASE month WHEN 1 THEN 1 WHEN 9 THEN 2 ELSE -1 END
    - use a Lookup table (sql join)
    - ...

    21 is only half the truth

  5. #5
    DEinspanjer Guest


    You could do it by performing the appropriate modulus in a JS step or by performing division and truncation in the Calculator step.

    Edit: I'd probably have to agree with Christoph that doing it in your Table Input step (i.e. in SQL) would be a little simpler. Depends on if there are more complex business rules that you are simplifying for us.

  6. Default Try the SQL Statement

    How about
    SELECT month, year, code, (month / 3) AS period FROM ....
    as SQL statement.

    See Operators and functions for some samples working in MYSQL.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.