cancel
Showing results for 
Search instead for 
Did you mean: 

Unit conversion in Calculated field

Former Member
0 Kudos

Hello

We have a field LENGTH coming from SAP which can be in INCHES or FEET,

The need is to convert LENGTH to Centimeters.

I have created a calculated field,"LENGTH(Metric)" which converts INCHES to CMS,but LENGTH can be in FEET too.

How do I write this expression in the calculated field?

I do not want to create assignments but use the calculated fields

Thanks

Kalyan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Kalyan,

do you have the uom in the same field?

Otherwise you could use something like that:

if(<uom field>="inches",<length>/2.54,<length>/30.48)

This tests whether the UOM field is "inch" and then divides the Length field by the factor 2.54, otherwise it divides by 30.48 (assuming it is "foot").

Hope that helps.

Best regards

Christian

Former Member
0 Kudos

Hi Christian

Thanks for that idea..I think it works..

For others searching the forum here is my code:

If(RIGHT(LENGTH,2)="in",MID(LENGTH,1,LEN(LENGTH)-2)*2.54 cms

Check the rightmost 2 characters of the LENGTH column is inches

ELSE
MID(LENGTH,1,LEN(LENGTH)-2)*30.4 cms)

multiplying by the factor after leaving out the UOM by using MID

Thanks

Kalyan