Hi,
I want to Round the decimal values to the nearest decimal value. I have a record with PRICE value = 13437.567 from input and it has Decimal (12,3) and I want output as 13437.57 and the output metadata is Decimal(12,2) . I used modify stage to achieve this
In Specification I mentioned
NEW_Price:Decimal = decimal_from_decimal [round_inf] (PRICE)
But Iam getting an NULL output
Thanks,
SomaRaju.
Decimal Rounding Problem
Moderators: chulett, rschirm, roy
Decimal Rounding Problem
somaraju
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Have you tried mapping decimal 12,3 to target decimal 12,2. Most of the cases it does rounding to the nearest value by default (Without using modify stage itself). If target is seq file in the 'edit metadata' option (which you get by clicking on left tab of field properties) you have an option to specify decimal type where you can tell how to round the source field to fit into the destination decimal when importing to a decimal.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Re: Decimal Rounding Problem
i saw a warning like this,When binding output interface field "Price" to field "New_Price": Conversion from source type "decimal[12,3]" to result type "decimal[1,0]": Possible range limitation.That may be the root cause you got Null value.
you can use a transformer stage,in derivation it's *DecimalToDecimal(DSLink3.Price,"round_inf")*,and output you can choose decimal(12,2).
However,i don't know to achieve this by modify stage,i don't know how to specify the output column option,e.g.decimal(12,2)
you can use a transformer stage,in derivation it's *DecimalToDecimal(DSLink3.Price,"round_inf")*,and output you can choose decimal(12,2).
However,i don't know to achieve this by modify stage,i don't know how to specify the output column option,e.g.decimal(12,2)
MaDFroG
Change your specification to
This should work.
Code: Select all
NEW_Price:Decimal[12,2] = decimal_from_decimal [round_inf] (PRICE)