3 Replies Latest reply: May 15, 2014 10:01 AM by Data Kruncher

# Feet and Inches conversion

Has anyone created any Monarch formulas to convert Feet and Inches into decimal?

I have two Excel UDFs that can convert back and forth, but they use FOR..NEXT loops, so it's not that easy to convert them to Monarch.

Here's a sample of my data:

Item               Size             Length

No-Hub Pipe           2             95'-4 7/8"

No-Hub Pipe           3             9'-8"

No-Hub Pipe           4             72'-3 5/8"

No-Hub Pipe           6             81'-1 7/8"

No-Hub Pipe           8             32'-0 7/8"

/code

• ###### Feet and Inches conversion

Bit sized bits here. Feel free to consolidate or otherwise optimize.

Trap the initial field as character, named "Pre Length". Now we need some calculated fields:

Pre Inches (character):

[SIZE=2]Strip(RSplit(,2,"-",1),'"')[/SIZE][/code]

Inches (numeric):

[SIZE=2]Val(LSplit(,2," ",1))[/SIZE][/code]

Fraction (character:

[SIZE=2]if(instr(" ",[Pre Inches])=0,"",RSplit(,2," ",1))[/SIZE][/code]

Decimal (numeric):

[SIZE=2]if(Fraction="",0,val(lsplit(Fraction,2,"/",1))/val(lsplit(Fraction,2,"/",2)))[/SIZE][/code]

Feet (numeric):

[SIZE=2]Val(LSplit(,2,"'",1))[/SIZE][/code]

Length (numeric):

[SIZE=2]Feet+Decimal[/SIZE][/code]

That, er, measure up for you?

Edit: I missed factoring in the inches, and dividing inches+decimal by 12 to get decimal feet!

So close and yet so far!

Final Length field should be:

[SIZE=2]Feet(InchesDecimal)/12[/CODE]

/SIZE

• ###### Feet and Inches conversion

PERFECT!

Two caveats:

Lengths less than a foot

The Feet formula becomes:

if(instr("'",[pre length])=0,0,Val(LSplit(,2,"'",1)))[/code]

Lengths in inches ( I forgot to mention this part)

The Final formula becomes:

(Feet*12)InchesDecimal[/code]

/LIST

It would be nice to convert it back, but since you wouldn't be able to use it in a measure for a summary anyway it doesn't matter. I can easily do that part in Excel.

• ###### Feet and Inches conversion

Excellent! Glad to see that you could take it the last mile.