5 Replies Latest reply on Dec 19, 2018 8:29 PM by Tony Machin

# substituting lower case to capital letters

Hey all,

Is there a way to substitute lower case to capital letters?  For example, from "chicken" to "Chicken"

I was thinking something in the lines of using LEFT() and Replace() to do this.  Something like:

IF LEFT("chicken",1) IS A LOWERCASE THEN REPLACE(LEFT("chicken",1), UPPER(LEFT("chicken",1)))

So to be more specific, I am looking for a way to check if a character is upper or lower case.

Thank you

Young

• ###### 1. Re: substituting lower case to capital letters

Hi Young, you can use ASCII to convert the first character to numeric (assuming you are talking about characters in the ASCII range).  The first lowercase letter ('a') is 97, so checking for a value less than 97 allows you to distinguish between upper and lower case.

http://www.asciitable.com/

You can use a calculation such as this to uppercase the first letter:

IF ASCII([field]) < 97 THEN
UPPER(LEFT([field],1)) + MID([field], 2)
ELSE
[field]
END

But you can make this even simpler since you don't even need to do a comparison, you can always convert the first letter to upper case:

UPPER(LEFT([field],1)) + MID([field], 2)

1 of 1 people found this helpful
• ###### 2. Re: substituting lower case to capital letters

Hi Jeff,  that is certainly one way I could tackle this issue.

Just curious, is there any features currently in the latest version of Tableau that circumnavigates the need to look up the ascii table?

• ###### 4. Re: substituting lower case to capital letters

Hi Young Song,

The following methods can be used to covert First Letter of String to Upper.

If you are getting the Data from Oracle to Tableau, We can use Function initcap at Oracle level.

I mean we can import before get the data into Tableau.

or

We get the result as First Letter Upper case, Irrespective what case it has.

upper(mid([Field], 1,1) ) + mid( [Field], 2, len([Field])

============

If you want to check whether first character is either Upper or Lower, we can use ASCII function as  Jeff D shared the solution.

Best Regards

Laxman Kumar

• ###### 5. Re: substituting lower case to capital letters

Hi Kumar,

just needed 1 extra ) on the end of that calculated field there.