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

Community site session details

Session Id : OdqFDjEKR6HduUqW6KIcsj
Power Apps - Building Power Apps
Answered

LEN & Numbers

Like (0) ShareShare
ReportReport
Posted on 5 Oct 2023 02:55:02 by 193

Hi Team,

 

I need to get the LEN of the item in my gallery which i'm doing by Len(ThisItem.Test).

 

Whatever the LEN returns say its 5 i need to have a 5 0's with a leading 1 Example (100,000)

If the LEN was 4 then (1,0000)

 

I just cant figure out how to convert the LEN into the number of 0's.

 

Any help is greatly appreciated.

 

Thanks

  • Verified answer
    Marshal_Jerome Profile Picture
    88 on 05 Oct 2023 at 05:30:41
    Re: LEN & Numbers

    Hi,

    You can use Power function as in below example.

     

    Power (10, Len (TextInput1.Text) +1);

     

  • Michael E. Gernaey Profile Picture
    46,678 Super User 2025 Season 2 on 05 Oct 2023 at 04:20:50
    Re: LEN & Numbers

    Hi @christian12 

     

    Ok now you could build this with a loop and some other things (especially if you create a custom control) but here is a little trick I made up, at least as far as I know, haven't seen it anywhere.

     

    I want you to create a TextLabel control, called it GetNumber. Make it invisible.

    For the Text value type in 10000000000 with 10 zeros, or if you need 20 zeros add 20 zeros. 

     

    Now when you get Len(ThisItem.Test) you want to add + 1 to it, so if the Len = 5 now make it 5 + 1, so 6.

    Let me explain. You said the Len is the # of zeros, and then you add a 1 to the beginning when makes the true len + 1

     

    Now lets say that you want to set another Text control to the value of Len(ThisItem.Test) to bla bla 100000.

    In the Text property of that control

    Type this code

    If(!IsBlank(ThisItem.Test), Left(GetNumber.Text, Len(ThisItem.Test) + 1),"")
    
    And it will return a number that is 1 + Len(ThisItem.Text) 0's...
    Note: I don't know what ThisItem.Test IS so IsBlank could be wrong to use there. but this will help insure you dont have any errors when ThisItem.Test is blank or empty or whatever you need to check
    
    :-)

     

    NOTE, if this is a Gallery, you do not have to add this invisible box to the Gallery, it just needs to be accessible 🙂 to the gallery controls, so as long as its on the screen. no worries.

     

    In my Sample here, I put a 1 and 30 zeros. And my GetNumbers Label is NOT invisible so you could see. 

    I put a TextInput, that I can type into

    I have another label under the GetNumbers, but it has no data yet because its Text property is set to this

    If(!IsBlank(InputStringToGetLenFrom.Text), Left(GetNumber.Text, Len(InputStringToGetLenFrom.Text) + 1),"")

    FLMike_0-1696479543936.png

    Now as I type

    FLMike_1-1696479607368.png

    Now I type 5 characters

    FLMike_2-1696479629402.png

     

    I hope this helps and if so please maybe Kudo and Set as Resovled for me.

    Thanks!


    Cheers
    If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete