Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Derived Column to process negatve sign with or without decimal point

$
0
0

HI,

I have had expert advise from the knowledgeable folks on this forum which solved my issues to date. I am trying to come up with one expression that will solve both issues I have.

I have flat file data which contains fields with implicit or explicit decimal points in the data and the gurus in this forum came up with this Derived Column expression:

So if I have a number like -000000000037.0 it will resolve to -37.00

ISNULL(PAID_AMT) ? NULL(DT_NUMERIC,18,2) : (TRIM(PAID_AMT) == "" ? NULL(DT_NUMERIC,18,2) : (FINDSTRING(PAID_AMT,".",1) > 0 ? (DT_NUMERIC,18,2)(TRIM(PAID_AMT)) : (DT_NUMERIC,18,2)(TRIM(PAID_AMT)) / 100))

I now have a number like 0000000000-2000 which needs to be resolved to -20.00

The following expression will do the proper conversion:

(DT_DECIMAL,2)((DT_DECIMAL,2)RIGHTPAID_AMT,(LENPAID_AMT) - FINDSTRING(PAID_AMT,"-",1) + 1)) / 100.0)

but I need ONE formula to handle both scenarios. Does such an expression exist. Is it possible to modify the first formula to handle both cases?

Can you help me out?

Thanks again for your help.

Dave


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>