Capitalize() returns the string with all
words in initial uppercase letters. Capitalize() function converts the first character of each word in a text string to uppercase and converts all other characters to lowercase.
Syntax:
Capitalize(text)
Return data type: string
Arguments
Argument
Description
text
The string to evaluate.
Example: Chart expressions
Example
Result
Capitalize( 'star trek' )
Returns Star Trek
Capitalize( 'AA bb cC Dd' )
Returns Aa Bb Cc Dd
Example - Capitalize fundamentals
Overview
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset which is loaded into a data table called Example.
One field in the data table called TextToCapitalize.
Load script
Example:
Load * inline [
TextToCapitalize
50 Cent
a-ha
BIGBANG
girl in red
];
Results
Load the data and open a sheet. Create a new table and add this field as a dimension:
TextToCapitalize
Create the following calculated dimension:
=Capitalize(TextToCapitalize), to calculate which characters to capitalize.
Results table
TextToCapitalize
Capitalize(TextToCapitalize)
50 Cent
50 Cent
a-ha
A-Ha
BIGBANG
Bigbang
girl in red
Girl In Red
There is no change to the first row of data as the first set of characters starts with a number and the second is already capitalized.
In the second row, the first and third characters are capitalized.
In the third row, only the first letter is capitalized, and all subsequent letters are set to lowercase.
In the fourth row, the first letter of each word is capitalized.
The following code shows how to use the function in a load script.
Load
String,
Capitalize(String)
Inline
[String
rHode iSland
washingTon d.C.
new york];
Results table
String
Capitalize(String)
rHode iSland
Rhode Island
washingTon d.C.
Washington D.C.
new york
New York
Example - Capitalize scenario
Overview
A dataset of customer names are entered using various formats, such as all lowercase, all uppercase, or mixed case. The Capitalize function is used to clean the data so that the customer's first and last name are properly capitalized when displayed in the dashboard.
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset which is loaded into a data table called Example.
One field in the data table called CustomerName.
Load script
Example:
Load * inline [
CustomerName
john smith
JANE DOE
miCHAel Brown
];
Results
Load the data and open a sheet. Create a new table and add this field as a dimension:
CustomerName
Create the following calculated dimension:
=Capitalize(CustomerName), to capitalize the customer names.
Results table
CustomerName
Capitalize(CustomerName)
JANE DOE
Jane Doe
john smith
John Smith
miCHAel Brown
Michael Brown
Compare the output of the Capitalize function to the original CustomerName string values that loaded in the script. You can see how the function successfully converted the names to use proper case. Displaying customer names with standardized capitalization improves the appearance, consistency, and readability of the dashboard.
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!