SharePoint Document Issues

How to Use the LEN Function for SharePoint List Column Validation

Huda QurayshiHuda Qurayshi Oct 26, 2026 869 views

Question details

The user needs to validate the specific length of data entered into a SharePoint list column using the LEN function, but is encountering syntax or list configuration errors.

How to Use the LEN Function for SharePoint List Column Validation
Product
Microsoft SharePoint
Device & OS
not provided
Scenario
Enforcing specific character lengths (e.g., a strict two-character code) for list column entries in SharePoint.
Observed behavior
The LEN validation formula may fail or return unexpected errors depending on the column type (Number vs. Text) or potential list corruption, sometimes requiring the list to be recreated.
Before you start

Ensure you have the appropriate site owner or list editor permissions to modify SharePoint list settings and column validation rules.

Solution 1Recommended

Configure Column Validation Using a Text Column

Apply the LEN function to a Single Line of Text column to enforce an exact character count, avoiding the data truncation issues associated with Number columns.

When using the LEN function, it is critical to use a Text column rather than a Number column. Number columns automatically strip leading zeros (e.g., '01' is stored as '1'), which changes the string length and causes the LEN validation to fail unexpectedly.

1
Access List Settings

Navigate to your SharePoint list, click the gear icon in the top right corner, and select 'List settings'.

2
Select the Target Column

Scroll down to the Columns section and click on the specific column you want to validate. Verify that the 'Type of information in this column is' set to 'Single line of text'.

3
Apply Validation Formula

Expand the 'Column Validation' section at the bottom of the settings page. In the Formula box, enter your LEN formula, such as =LEN([Fund])=2.

4
Add a User Message and Save

Type a helpful explanation in the 'User message' box (e.g., 'This field requires exactly 2 characters'). Click 'OK' to save your settings.

Configure Column Validation Using a Text Column
Syntax Formatting: Ensure you use the exact column name within the brackets. If your column name contains spaces, you must still include the brackets, for example: =LEN([Fund Code])=2.
Free Microsoft Office alternative

Analyze Your SharePoint Data Easily with WPS Office

While SharePoint handles online list validation, you often need to export these lists for deep offline analysis. WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office for editing Excel spreadsheets, analyzing exported list data, and managing your daily documents.

  1. 1. Export SharePoint List: In your SharePoint list, click 'Export' and select 'Export to Excel' to download your validated data as an .iqy or .xlsx file.
  2. 2. Open with WPS Spreadsheet: Launch WPS Office and open the downloaded Excel file to view your SharePoint list offline.
  3. 3. Analyze Data: Use WPS Spreadsheet's built-in formulas, pivot tables, and filters to analyze your data seamlessly.
Fully compatible with Microsoft Excel (.xlsx) formats exported directly from SharePointLightweight application that runs smoothly on Windows, Mac, Linux, and mobile devicesFamiliar user interface requires no learning curveFree to use for everyday document and spreadsheet management
microsoft office alternative - wps office

Frequently Asked Questions

Why does =LEN([ColumnName])=2 fail on a SharePoint Number column?

Number columns automatically format entries by stripping out leading zeros (e.g., '01' becomes '1'). This reduces the character length of the string, causing the strict 2-character LEN validation to fail. Always use a 'Single line of text' column for exact character length validation to preserve formatting.

Can I use the LEN function to set a maximum length instead of an exact length?

Yes. You can use less-than or equal operators to define a maximum limit. For example, entering =LEN([ColumnName])<=10 ensures the user enters no more than 10 characters in the field.

How do I combine LEN with other validation rules in SharePoint?

You can use the AND function to combine multiple validation rules. For example, =AND(LEN([ColumnName])=5, [ColumnName]<>"ERROR") ensures the data entry is exactly 5 characters long and does not equal the word 'ERROR'.