web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using LEN to size a te...
Power Apps
Answered

Using LEN to size a text input box

(0) ShareShare
ReportReport
Posted on by 716 Moderator

So the goal is to size a text input control based on the text entered.

Here is what I have so far which logically makes sense but I obviously have errors cause it doesn't work.

Min(250, Max(60, 40 * RoundUp(CountRows((Len(DataCardValue6.Text)) / DataCardValue6.Width, 0))))

I've also tried this which doesn't work. My thought being that DataCardValue6 may not have an actual value when the expression is processed.

Min(250, Max(60, 40 * RoundUp(CountRows((Len(Parent.Default)) / DataCardValue6.Width, 0))))

 

Categories:
I have the same question (0)
  • v-mengmli-msft Profile Picture
    Microsoft Employee on at

    Hi @DCHammer ,

     

    CountRows is used to count items of table. I'm afraid it can't be used as below.

    CountRows((Len(DataCardValue6.Text))

    Here is a method for your reference.

    Width of TextInput.

    Min(250,Max(60,40*Len(Self.Text)))

     

    Best regards,

    Rimmon

  • Verified answer
    DCHammer Profile Picture
    716 Moderator on at

    That doesn't work the way I wish. I changed the first value in the Min statement to 60 because I want the input box to be small and fit the design. But when I change the 250 to 60 as below, the result is as attached in the image.

     

    Min(60,Max(60,40*Len(Self.Text

     

    DCHammer_0-1712080639661.png

    It seems that the issue is that 40*Len(Self.Text) produces very large numbers because it represents character count. So for the given content, it's 11280. 

     

    This is what works. I didn't need the initial Min statement at all. Just the Max. I may have to modify the multiplier I'm using on the Len calculation for other controls and it may blow up when the form is resized. I'll review responsiveness later. But I'm expecting that the control width is set by the parent(s) so it should still work. 

    Max(60, 40 * (Len(DataCardValue6.Text))*4.8 / DataCardValue6.Width, 0)

    This is the result:

    DCHammer_1-1712088293718.png

     

    DCHammer_0-1712088255538.png

     

    And it works when the form is in Edit mode so the control grows as text is input.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 633

#2
11manish Profile Picture

11manish 588

#3
Valantis Profile Picture

Valantis 457

Last 30 days Overall leaderboard