Hello,
I hope the following is not a FAQ.
I have a problem using BigDecimal (and tMap)
Practically, I have the main flow "row9" containing 2 BIGDECIMAL columns CLOTHUSAGE and SUMQTY and I need to print in a CSV file an AVG which basically is CLOTHUSAGE/(SUMQTY*10000)
btw If I extract their values they are correct..
CLOTHUSAGE SUMQTY
275021 42
445140 40
607115 220
745800 60
7047275 1300
I am using a tMap in order to add a column AVG to my main output flow
The problem is the following
If I divide one for the other with the following formula
(row9.CLOTHUSAGE != null && row9.SUMQTY != null)? row9.CLOTHUSAGE.divide(row9.SUMQTY, 0, BigDecimal.ROUND_FLOOR):new BigDecimal(0)
the results in the CSV are correct
CLOTHUSAGE SUMQTY AVG
275021 42 6548
445140 40 11128
607115 220 2759
745800 60 12430
7047275 1300 5420
But as I said I would need these numbers in a CSV in another scale (/10000) as the following
0.6548
1.1128
0.2759
1.2430
0.5420
So I have tried to set the target column of the tMap output flow as the following
(row9.CLOTHUSAGE != null && row9.SUMQTY != null)? row9.CLOTHUSAGE.divide(row9.SUMQTY.multiply(new BigDecimal(10000)), 5, BigDecimal.ROUND_FLOOR):new BigDecimal(0)
And here is the strange thing
I obtain the following unexpected (at least for me) result
0.65481
111.285 (KO)
0.27596
124.300 (KO)
0.54209
What am I doing wrong?
Thanks in advance for any suggestion
An update...
putting a tLogRow the data I see in the console are correct, so the problem seems to be in the way I use the tFileOutputDelimited Component
VindalooMan
A last update (and closing the issue)
This morning I have tried opening the CSV with a text editor and not with Excel (sigh) and the data are correct.
So it is a matter of visualization in Excel...
sorry for non checking it before 😐 Ciao
hi
Can we compare BigDecimal value with null ,i tried using row1.col==null?0:row1.col
but getting the following error in tmap
Type mismatch:cannot convert from number and comparable<?>to BigDecimal