You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Tableau中将固定长度字符串拆分为多列?

How to Split a Fixed-Length String (Letter + 5 Digits) into Two Columns in Tableau Desktop 10.x

Hey there! Since your string follows a strict fixed format (1 leading letter + 5 digits, e.g., A12345), splitting it into separate letter and number columns is totally straightforward using Tableau's built-in string functions. Here's a step-by-step breakdown:

Step 1: Create a Calculated Field for the Leading Letter

  1. In your Tableau workbook, right-click the original string field in the Data pane and select Create > Calculated Field.
  2. In the calculation editor, use the LEFT() function to grab the first character:
    LEFT([Your Original Field Name], 1)
    
    Replace [Your Original Field Name] with the actual name of your string column. This function pulls the leftmost 1 character, which is exactly your leading letter.
  3. Name the field something like "Leading Letter" and click OK.

Step 2: Create a Calculated Field for the 5-Digit String

You have two equally reliable options here:

Option A: Use RIGHT() (Simpler for Fixed Length)

  1. Create another calculated field the same way as Step 1.
  2. Use the RIGHT() function to pull the last 5 characters:
    RIGHT([Your Original Field Name], 5)
    
    This works perfectly because your digits are always the final 5 characters in the string.

Option B: Use MID() (Target Specific Position)

If you prefer to specify the starting position instead of counting from the end, use MID():

MID([Your Original Field Name], 2, 5)

This starts at the 2nd character (skipping the leading letter) and pulls the next 5 characters.

Bonus: Convert Digits to Numeric Type (If Needed)

If you want the digit column to be a numeric type (instead of a string) for calculations, wrap the function in INT():

INT(RIGHT([Your Original Field Name], 5))

That's it! Both new fields will show up in your Data pane, and you can use them just like any other column in your visualizations.

内容的提问来源于stack exchange,提问作者Jeffrey Levy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:35:26