Page 1 of 1

Dynamic Decimal Point

Posted: Tue Mar 22, 2011 12:09 pm
by devidotcom
Hi All,

I have a scenario where I get the number of decimal points dynamically.

For example:
If the incoming column value for C1 is 2 then C2 must be multipled by C2*0.01
If the incoming column value for C1 is 4 then C2 must be multipled by C2*0.0001

Basically i need to multiple C2 in this way
C2 * (1/10 ^C1 value)

Any suggestions on how to implement this logic?

-Thanks

Posted: Tue Mar 22, 2011 12:30 pm
by jwiles
Looks like C1 is a column on the incoming data, correct? And it can change from record to record?

Assuming so:

a) If C2 is a string, just use Left(), Right(), Len(), '.' and a little math to insert the decimal point
b) If C2 is a decimal, use the Pwr() function, as in MyValue = Pwr(10,C1), then C2 = C2 / MyValue

Regards,

Posted: Tue Mar 22, 2011 11:55 pm
by devidotcom
Yes, C1 column is an input column.

I tried the second option and it works.

Thanks & Regards,
Devi