Pentaho

 View Only

 select value component rounding data

  • Pentaho
  • Kettle
  • Pentaho
  • Pentaho Data Integration PDI
archana garikapati's profile image
archana garikapati posted 06-17-2019 21:30
Naveen Kumar's profile image
Naveen Kumar

Archana, The precision is defined as 2 in the Select Values step metdata tab. Due this, the values are rounded off to 2 decimal places.

archana garikapati's profile image
archana garikapati

yes i want them to round off by 2 decimals but again sum of colval2 + value4 should be equal to 6 as per rules. it is failing even if it doesnt match the decimal count.

Naveen Kumar's profile image
Naveen Kumar

If the aggregated value (Val2+val4) is rounded and then compared against sum of individually rounded values (Val2 and Val4) - This may not necessarily match absolutely as the rounding policy is different and precision is lost during rounding.

Consider computing Val6 after Val2 and Val4 is rounded to 2 decimals, or consider higher precision.

David da Guia Carvalho's profile image
David da Guia Carvalho

If you still need more control over your numbers, how about trying a "calculator" step at the end of your process to round the numbers for you?

From 8.x PDI have the option of "ROUND_CUSTOM" and in your case I would bet on somthings like:

B - Constant value 3 - ( for 3 digits)

C - Constant value 3 - (For decimal Floor)

ROUND_CUSTOM(A,B,C) - YourValue,B,C

You can also play with the mask.

References: 

https://help.pentaho.com/Documentation/8.2/Products/Data_Integration/Transformation_Step_Reference/Calculator

ROUND_CUSTOM( A , B , C )

Rounds B using a specific type of rounding mode indicated by C (see list). Calculates using the same conditions as the ROUND_CUSTOM( A , B ) function with the following exceptions:

  • Field C is the rounding mode to be used (see list).
  • Field B is the decimal value where the rounding is to take place. For example, if A is '1667.2342', B is '3', and C is '2', then 1667.2342 will round to 1667.235 since the CEILING rounding mode is applied which rounds up the third decimal value "4" to a "5".

Rounding Modes:

  • 0 - UP: Rounding mode to round away from zero.
  • 1 - DOWN: Rounding mode to round towards zero.
  • 2 - CEILING: Rounding mode to round towards positive infinity.
  • 3 - FLOOR: Rounding mode to round towards negative infinity.
  • 4 - HALF_UP: Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
  • 5 - HALF_DOWN: Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
  • 6 - HALF_EVEN: Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.
  • 7 - UNNECESSARY: Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary.
archana garikapati's profile image
archana garikapati

i am still using pentaho 5 version. what would be the alternative

David da Guia Carvalho's profile image
David da Guia Carvalho

If you dont find any other option... you could split the number, floor the decimal, and put then together again.