Blaž Čukelj
Blaž Čukelj

Reputation: 83

Pentaho: How to rollup time

I have time for example I have in records time written in this way: 00:02:24 or 15:22:45, and now I want to make another column (hours), where can be values for example for time 02:43:22 is value 2, or for time 23:22:14, is value 23 and so on. But I don't know how can I do that, I tried number range, but unsuccessfully.

Here is a picture, how i want to be:

Time And Hours

Thanks.

Upvotes: 0

Views: 135

Answers (1)

AlainD
AlainD

Reputation: 6356

You can use the Modified JavaScript Value step.

I do not know which type is your Time.

  • If it is a String, a var Hour = Time.substr(0,2); will do.
  • If it is a Date, use var Hour = Time.getHour();.
  • If the type is something else, then convert in a String first.

enter image description here

To do this:

  1. drag-and.drop the step Modified JavaScript Valueand link it to the data flow provider (in the example a Data grid).
  2. edit this step and add your script. (Note that you can quickly add the input variable with a double click. Note also that clicking on the Transformation Function in the left menu gives you the list of available function additional to the Javascript built-in collection).
  3. Click on the Get variable button, keep the variable you need (here Hour), and define/redefine its type (here String).
  4. That's done: OK and preview.
  5. If needed, adapt to the type of your input flow. For example Hour = Hour+'' to force a type conversion into a String.

Upvotes: 1

Related Questions