Skip to main content

How to Limit Text Length and Show a Character Count in Power Apps

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

Long text needs a limit, and people need to see how close they are to it. Set the text input's MaxLength, and add a label that counts what's typed: 247 of 4,000 characters.

Prerequisites​

The example is the Career Development Plan app's Response screen.

Step 1: Name the Limit Once​

The limit appears in two places, the input and the count, so give it a name in App.Formulas (How to Use Named Formulas in Power Apps):

App → Formulas (added)
ResponseMaxLength = 4000;

Step 2: Set MaxLength​

txtResponseRS → MaxLength
ResponseMaxLength

The formula bar with the MaxLength property of txtResponseRS set to ResponseMaxLength and the preview strip reading ResponseMaxLength = 4000 with Data type number

Microsoft's reference: MaxLength is "the maximum number of characters allowed in the input field. Users cannot type beyond this limit" (Text Input modern control). In the example it was empty until set.

Step 3: Count the Characters​

Len counts the characters typed (How to Count Characters in Power Apps with Len), and Text writes the limit with a thousands separator (Convert Number to Text):

lblCountRS → Text
Len(txtResponseRS.Text) & " of " & Text(ResponseMaxLength, "#,##0") & " characters"

The formula bar with the counter formula selected and the preview strip reading = 316 of 4,000 characters with Data type text

The input's TriggerOutput is Keypress by default, so the count follows every key. In preview, with a paragraph typed:

The Response screen in preview with a typed paragraph and 247 of 4,000 characters below the box

Set the count's AccessibleLabel to Self.Text so screen readers read the same words.

Variations​

ShowFormula
Characters left(ResponseMaxLength - Len(txtResponseRS.Text)) & " characters left"
Only near the limitPut the count's Visible on Len(txtResponseRS.Text) > ResponseMaxLength - 200

Common Mistakes​

MistakeWhat happensDo this instead
4000 typed in both placesThey drift apart when one changesOne named formula
Text(4000) without a format4000, harder to readText(ResponseMaxLength, "#,##0")
Counting DefaultThe count doesn't moveCount txtX.Text

Troubleshooting​

SymptomLikely causeFix
The count updates only when leaving the boxTriggerOutput isn't KeypressSet it back to TriggerOutput.Keypress
The count is hiddenA Visible formula hides itCheck its Visible

FAQ​

Should the limit match the SharePoint column?​

It should be no larger than what the column can store. The example's Response column is multiple lines of plain text; the app chose 4,000 characters as a sensible length for one answer.

Does Len count spaces?​

Yes. It counts every character, including spaces and line breaks.

Conclusion​

Name the limit once, set MaxLength to it, and show Len(txtX.Text) & " of " & Text(Limit, "#,##0") & " characters" under the box.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.