How to Use the LEN Function for SharePoint List Column Validation
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.

- 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.
Ensure you have the appropriate site owner or list editor permissions to modify SharePoint list settings and column validation rules.
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.
Navigate to your SharePoint list, click the gear icon in the top right corner, and select 'List settings'.
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'.
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.
Type a helpful explanation in the 'User message' box (e.g., 'This field requires exactly 2 characters'). Click 'OK' to save your settings.

Recreate the List to Resolve Persistent Errors
If the correct LEN formula consistently returns an error despite perfect syntax, the list structure may be corrupted and needs to be rebuilt.
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. 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. Open with WPS Spreadsheet: Launch WPS Office and open the downloaded Excel file to view your SharePoint list offline.
- 3. Analyze Data: Use WPS Spreadsheet's built-in formulas, pivot tables, and filters to analyze your data seamlessly.

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'.




