5 Replies Latest reply on Sep 23, 2014 3:44 PM by Matthew Kopetsky

# Concatenate Integer + String

Hi,

I have a calculcated field that looks like this:

CASE [Parameter]

WHEN "String A" THEN Sum([Measure A])

WHEN "String B" THEN Sum([Measure B])*100

END

Measure A is an integer but Measure B is a percentage. I want to display the "%" and tried to change the formula as:

WHEN "String B" THEN Sum([Measure B])*100+"%"

It does not work.

Is there a workaround?

Thank you!

Thierry

• ###### 1. Re: Concatenate Integer + String

You've probably tried this, but what about converting them to strings

CASE [Parameter]

WHEN "String A" THEN STR(Sum([Measure A]))

WHEN "String B" THEN STR(Sum([Measure B])*100)+"%"

END

Or course this makes everything a string, but maybe that's OK for you. Another tip is that if you wrap the calculation in LOOKUP(), the formatting is preserved. STR(LOOKUP(Sum([Measure A]),0)

2 of 2 people found this helpful
• ###### 2. Re: Concatenate Integer + String

Hi Jim,

Sorry for the late follow-up et thanks a lot for stepping in.

I have tried every possible solution but I don't think I can make it work. I am using this parameter on a filled map where I need it to be returned as a measure in order to generate gradient fill.

Also when converting them all to string I can't control the number of decimals in my percentage calculcation.

Guess I'll have to create 2 different dashboards: one for each measure. If only there would be a "FORMAT" function in Tableau!

• ###### 3. Re: Concatenate Integer + String

Hi Thierry,

Any update on this? Im bumbing into the same problem.

Thanks

Joao

• ###### 4. Re: Concatenate Integer + String

You may be able to use the String for formatting and the original measure for the gradient. Have you tried that?

• ###### 5. Re: Concatenate Integer + String

You'll need to convert your calculated field to a string before concatenating it with a text value:

`WHEN "String B" THEN STR(Sum([Measure B])*100)+"%"`

However, this will give you a floating decimal for most calculations so you may also need to round the calculated field as follows:

`WHEN "String B" THEN STR(ROUND(Sum([Measure B])*100,2))+"%"`
1 of 1 people found this helpful