Rounding off issue with datastage
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 536
- Joined: Thu Oct 11, 2007 1:48 am
- Location: Bangalore
Rounding off issue with datastage
Hi,
I am facing rounding off issue in datastage.In my job Source and Target are oracle. Source datatye is Float and target it is Decimal(14,2).
In target table data is getting rounded for ex:-
Source Selling value
134.64912280701754385964912280701754386
Target Selling value
134.65
But my expected output is 134.64.
I tried to apply below function in transformer
DecimaltoDecimal(Selling Value,'floor')
In this case my output is :-
Source Selling value
134.64912280701754385964912280701754386
98.24000000000000000000000000000000000026
Target Selling value
134.64
98.23
But our expected output is :-
134.64
98.24
Can anyone suggest us to achieve this result?
I am facing rounding off issue in datastage.In my job Source and Target are oracle. Source datatye is Float and target it is Decimal(14,2).
In target table data is getting rounded for ex:-
Source Selling value
134.64912280701754385964912280701754386
Target Selling value
134.65
But my expected output is 134.64.
I tried to apply below function in transformer
DecimaltoDecimal(Selling Value,'floor')
In this case my output is :-
Source Selling value
134.64912280701754385964912280701754386
98.24000000000000000000000000000000000026
Target Selling value
134.64
98.23
But our expected output is :-
134.64
98.24
Can anyone suggest us to achieve this result?
Thanks
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
-
- Premium Member
- Posts: 536
- Joined: Thu Oct 11, 2007 1:48 am
- Location: Bangalore
Hi Bob,
No Luck,with first function but second one is almost correct,but for some folting number its not working properly
With Function DecimalToDecimal(mylink.mydec,"trunc_zero")
Input
142.543859649122807017543859649122807018
4278.02631578947368421052631578947368421
212.157894736842105263157894736842105264
334.900000000000000000000000000000000001
409.750000000000000000000000000000000001
Output
142.54
4278.02
212.15
334.89
409.75
For 334.900000000000000000000000000000000001 i am getting output as 334.89 but i am expecting 334.90
No Luck,with first function but second one is almost correct,but for some folting number its not working properly
With Function DecimalToDecimal(mylink.mydec,"trunc_zero")
Input
142.543859649122807017543859649122807018
4278.02631578947368421052631578947368421
212.157894736842105263157894736842105264
334.900000000000000000000000000000000001
409.750000000000000000000000000000000001
Output
142.54
4278.02
212.15
334.89
409.75
For 334.900000000000000000000000000000000001 i am getting output as 334.89 but i am expecting 334.90
Thanks
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
-
- Premium Member
- Posts: 536
- Joined: Thu Oct 11, 2007 1:48 am
- Location: Bangalore
Hi,
Can someone help me with above issue?
Can someone help me with above issue?
Thanks
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
-
- Premium Member
- Posts: 536
- Joined: Thu Oct 11, 2007 1:48 am
- Location: Bangalore
Hi,
My input is float and target is decimal(14,2) which i cant change it.
My input is float and target is decimal(14,2) which i cant change it.
Thanks
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
-
- Premium Member
- Posts: 376
- Joined: Sat Jan 07, 2012 12:25 pm
- Location: Piscataway
This solution may not be optimal but will serve as a work-around while you search a better solution
I haven't actually implemented it. Do let me know if it works.
Note: You might want to add a StringToDecimal just in case
Code: Select all
Left(col,Index(DecimalToString(col),".",1)+2)
Note: You might want to add a StringToDecimal just in case
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
-
- Premium Member
- Posts: 536
- Joined: Thu Oct 11, 2007 1:48 am
- Location: Bangalore
Hi Ranjan,
Thanks for your reply but it seems its not working.
Input
212.157894736842105263157894736842105264
Output
212.16
Thanks for your reply but it seems its not working.
Input
212.157894736842105263157894736842105264
Output
212.16
Thanks
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
-
- Premium Member
- Posts: 376
- Joined: Sat Jan 07, 2012 12:25 pm
- Location: Piscataway
Ok, this should work
Code: Select all
Left(DecimalToString(col),Index(DecimalToString(col),".",1)+2)
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
-
- Premium Member
- Posts: 536
- Joined: Thu Oct 11, 2007 1:48 am
- Location: Bangalore
Hi,
Thank you very much its working....
But i have around 8-10 coumnls like this,will it be good approach to convert it like this?
Anyways for time being its fine for me.
Thank you very much its working....
But i have around 8-10 coumnls like this,will it be good approach to convert it like this?
Anyways for time being its fine for me.
Thanks
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
Prasoon
ETL Consultant
LinkedIn :- http://www.linkedin.com/profile/view?id ... ab_pro_top
Blog:- http://dsshar.blogspot.com/
-
- Premium Member
- Posts: 376
- Joined: Sat Jan 07, 2012 12:25 pm
- Location: Piscataway
Can't think of anything other than replicating the same logic.
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
You can try derivation substitution in transformer.
The conversion using trunc_zero may not always work as it depends on how many decimal points the database and datastage supports for float. For example oracle supports many decimal points more that float in datastage. You many need to change the datatype in datastage to double to make it more accurate. However if the solution provided earlier works for you then no point in changing the same.
The conversion using trunc_zero may not always work as it depends on how many decimal points the database and datastage supports for float. For example oracle supports many decimal points more that float in datastage. You many need to change the datatype in datastage to double to make it more accurate. However if the solution provided earlier works for you then no point in changing the same.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.
Genius may have its limitations, but stupidity is not thus handicapped.
-
- Participant
- Posts: 34
- Joined: Tue Feb 26, 2013 9:36 am
- Location: Chicago