Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Using LEN to size a text input box

(0) ShareShare
ReportReport
Posted on by 714 Super User 2025 Season 1

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:
  • Verified answer
    DCHammer Profile Picture
    714 Super User 2025 Season 1 on at
    Re: Using LEN to size a text input box

    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.

  • v-mengmli-msft Profile Picture
    on at
    Re: Using LEN to size a text input box

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard