5 Replies Latest reply on Jun 2, 2012 3:36 PM by Richard Leeke

# Converting Feet to Inches?

Hello All!

I'm a brand new Tableau user (2 days) and I was hoping someone might be willing to help with a conversion problem I'm facing.

My problem is that I have height data that was captured in feet and inches, instead of in inches.  The cell data is captured as:  [ 5'7" ] with the foot and inch suffix.

I'd like to do a BMI calculation in the Viz that requires the height data be in Inches, but can't seem to come up with a Field Calculation for the conversion from Feet and Inches to Inches?  Is there a work around in Tableau for problematic formatting?   Any help would be so appreciated!

Thank You!

• ###### 1. Re: Converting Feet to Inches?

INT(LEFT([Height (feet and inches)],

FIND([Height (feet and inches)],"'") - 1)) * 12

+

INT(MID([Height (feet and inches)],

FIND([Height (feet and inches)],"'") + 1,

LEN([Height (feet and inches)]) - FIND([Height (feet and inches)],"'") - 1))

• ###### 2. Re: Converting Feet to Inches?

Wow!, just Wow!

Thank you Richard for such an elegant solution, it'll take me a bit to digest the syntax, although I'm happy to say I'm following the basic commands.  If you don't mind me asking, as a newb non coder, are there any resources you might suggest that present a short course on how and when to use the calculations in Tableau?

Thanks so much for the answer, I'll be spending a few hours trying to figure out why it's correct!

All the best

• ###### 3. Re: Converting Feet to Inches?

The Tableau on-line training resources are excellent - but it's a long time since I've looked at them so I can't point to specifics. I'm pretty sure that one of the videos does focus on calculations.

I've got a software background, so tend to just take it for granted.

Be warned that the calculation I gave you doesn't handle the case where the input isn't formatted exactly as you described (so for example, I'm not sure what it would do with 6' instead of 6'0"). It's hard to do that in Tableau calculations.

• ###### 4. Re: Converting Feet to Inches?

I find this site to have some great posts: http://www.theinformationlab.co.uk/blog/

If your data is differently formatted you can special case the equation using something like if len([Height])<4 then xyz else abc end

• ###### 5. Re: Converting Feet to Inches?

Yeah - unless we're talking giraffes here I think it's safe to assume 1 digit for the feet ...