Dynamic Decimal Point

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Dynamic Decimal Point

Post 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
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post 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,
- james wiles


All generalizations are false, including this one - Mark Twain.
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

Yes, C1 column is an input column.

I tried the second option and it works.

Thanks & Regards,
Devi
Post Reply