1 2 Previous Next 27 Replies Latest reply on Jul 24, 2014 9:13 AM by sandrine lhuissier

# Convert calculated field into float

Hi,

I ve create a calculted field with this formula:

Longitude = (TRIM(LEFT([geo_coordinates],FIND([geo_coordinates],",")-1)))

geo_coordinates is a String like "48.884079, 2.37615"

i 'd like to obtain 2 float number:

Longitude = 48.884079

and

Lattitude = 2.37615

But i cant' convert the calcultated string field into a float number

Anyone?

Thnaks

• ###### 1. Re: Convert calculated field into float

Have you tried the FLOAT function?

FLOAT([string])

If you FLOAT("48.884079"), for example, it returns a numeric value of 48.884079.

It would look something like:

FLOAT((TRIM(LEFT([geo_coordinates],FIND([geo_coordinates],",")-1))))

• ###### 2. Re: Convert calculated field into float

Yes i tried

i obtained "null" for each value

• ###### 3. Re: Convert calculated field into float

Works for me.

See attached.

I have a calc field (Calculation1) that simulates your data.  (value = "48.884079,2.37615")

I have a second calc that does the manipulation I suggested:

FLOAT((TRIM(LEFT([Calculation1],FIND([Calculation1],",")-1))))

I display it in the Title of the sheet.

• ###### 4. Re: Convert calculated field into float

i see the "Tout" value in the title

but i d like all values on the colums or lines

• ###### 5. Re: Convert calculated field into float

Well of course.  I was just showing that it could work.  Tossing things into the TITLE is an easy way to test things out.  That's all.

So the FLOAT works.  Look at what I did, and look at what you did (that generated NULL instead) and see what's different.  I don't have your workbook, so you'll have to take it the next step.

Start with this:  When you do the TRIM, etc., can you display the string results on each row?  If not, then the problem is not in the FLOAT.  Get the string value to display first.  If you already can display the string value, then it should be a simple matter of encasing that withing the FLOAT().

• ###### 6. Re: Convert calculated field into float

there is no difference between yours and mine

The same thing happened : the title is "tout"

I tried also with the String field and put it ont the lines, The display is ok.

But with the float it still not working

• ###### 7. Re: Convert calculated field into float

OK, I didn't understand that the first time.

Are you saying that when you open FloatExample.twbx in tableau, the title string for sheet-1 is "tout" and not 48.884079 ?

I get 48.884079 on both 8.1 an 8.2.  I'm not sure what you are seeing.

Maybe you need to post an example of your workbook here.

• ###### 8. Re: Convert calculated field into float

that s what i see with your example

• ###### 9. Re: Convert calculated field into float

I have no idea why you see that.

You'll need to post a packaged example of your workbook.

• ###### 10. Re: Convert calculated field into float

i think maybe the answer is on the local parameter

what is the language of your local parameter?

• ###### 11. Re: Convert calculated field into float

Tout is french for "All." the reason you're seeing "All" is because you're applying ATTR aggregation.  It's getting multiple values for 1 location (The title)

You need to do a max or min agg to see that the value is coming over correctly if you're going to put it in the title to test.

• ###### 12. Re: Convert calculated field into float

I'm working in English.  I noticed your screen shot shows Francais.  If that's the problem, I don't know how to adress that.

Ah.  In French, "Tout" means "All".  And that's a potential result from a calc field not being handled correctly.  But I don't get "All" here.  I get 48.884079.  There are no rows.  Only one possible value.  (Tableau displays "All" (or "Tout" in French) if there are multiple values for a single output.)

I don't know what to say at this point.

• ###### 13. Re: Convert calculated field into float

Aaron.  I don't have multiple rows.  I don't have any rows.  Not in the example I posted anyway.

• ###### 14. Re: Convert calculated field into float

Joe I was talking to Sandrine.

Your data has a single value for your calc.  This will never change so it doesn't matter what aggregation you use, it will always be the same for every record.

Sandrine has "real" data that isn't the same value repeating down the data set.  This will cause an "All" result because Tableau doesn't know which one to show.

Putting a calc on the title to check syntax can be a bad way to troubleshoot for that reason.

1 2 Previous Next