Hi Friends,
I am trying to rounding of a Decimal based on a Parameter, which will give the length of digits after decimal points.
When I am trying to use DecimalToDecimal() function, I need to use the Datatype as required, so I am not able to provide the Parameter for Rounding.
Any idea how I can round the decimal based on parameter is much appriciated.
Regards,
Pksahu
Decimal Rounding based on Parameter
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
I suspect this is not possible. What have you tried, and with what result?
Have you considered a Modify stage? Pretty much everything in a Modify stage can be parameterized.
Have you considered a Modify stage? Pretty much everything in a Modify stage can be parameterized.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
One possible solution would be to multiply your value by an appropriate power of 10, round the number and then divide by the same power of 10. Example:
Number of digits requested: 3
10**3 = 1000
Value: 12.45823
Value*1000 = 12458.23
Rounded = 12458.00
Rounded/1000 = 12.45800
This is simply one way to handle it through only math, but does not adjust the actual schema of the column. If required as well, that would require the modify solution proposed by Ray. The math can be done in stage variables, just ensure that they are defined large enough to handle the results of the multiplication and division.
Regards,
Number of digits requested: 3
10**3 = 1000
Value: 12.45823
Value*1000 = 12458.23
Rounded = 12458.00
Rounded/1000 = 12.45800
This is simply one way to handle it through only math, but does not adjust the actual schema of the column. If required as well, that would require the modify solution proposed by Ray. The math can be done in stage variables, just ensure that they are defined large enough to handle the results of the multiplication and division.
Regards,
- james wiles
All generalizations are false, including this one - Mark Twain.
All generalizations are false, including this one - Mark Twain.
Thanks James.
The scenarios is like below: I have some derivation based on The Rate,Qty, Discount and then doing some percentage calculation. After that based on the [b]Currency precission[/b], I am doing the round up.
By applying your math formula, it worked perfectly.
Thanks a lot for all the help. Much appriciated.
The scenarios is like below: I have some derivation based on The Rate,Qty, Discount and then doing some percentage calculation. After that based on the [b]Currency precission[/b], I am doing the round up.
By applying your math formula, it worked perfectly.
Thanks a lot for all the help. Much appriciated.