・Problem:
When dealing with numbers like 1, 10, and 100, they have different character lengths, which can lead to inconsistency in formatting—especially when displaying them in aligned columns or storing them in fixed-length fields.
・Goal:
How to pad each number with leading zeros so that all numbers are exactly 5 characters long. For example:
Original: 1 10 100
Padded: 00001 00010 00100
・How to achieve this:
Use a method or function that pads the number with leading zeros until the desired string length is reached.
To format a numeric field by padding it with leading zeros, follow these steps to create and apply a calculated field in Tableau.
1.Open your Tableau worksheet and navigate to the Data pane.
2. Identify the numeric field you want to format.
For example, suppose your dataset has a field called mynumber that contains values like 1, 10, and 100.
*[mynumber] refers to this numeric field in your data source.
3. Create a new calculated field:
・Right-click on the Data pane and select Create Calculated Field…
・Name the field something like Padded Number.
4. Enter the following formula into the calculation editor:
RIGHT("00000" + STR([mynumber]), 5)
5. Click OK to save the calculated field.
6. Drag and drop the new Padded Number field onto your view (e.g., into a table or label) to see the result.
005104685

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.