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 / How to add zeros at th...
Power Apps
Answered

How to add zeros at the start on Id

(0) ShareShare
ReportReport
Posted on by 82

Hey team,

I was wondering if someone has come across this issue. I have a field in my form called position id which I need to increment from the back end by 1. But my total number should be of 6 digits. For example my incremented id is suppose 501 but I want to Patch it as "000501" to maintain the uniformity. Please suggest me how to write the code to append zeros at the start depending on the number of digits the positionid column has. Also my positionid column is  string datatype.

I'm using this formula to get the last position id:

First(Sort(ListName,Positionid,Descending)).PositionId+1

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    What you can do is to start the first number with 100000.

     

    That way, increment by one would be ok. Example 100001

    First(Sort(ListName,Positionid,Descending)).PositionId+1

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • skd Profile Picture
    82 on at

    Hey  @eka24 ,

     Actually the PostionId is already a column in my company data and I just have to create a power app for it and they have standard way of writing it with zeros at the start.Therefore pls help me to add the logic accordingly. 

     

  • eka24 Profile Picture
    20,925 on at

    If they are already in your Datasource then create another column, a calculated column with the formula:

    Text(PositionId,"000000")

    Or

    Right (PositionId&"000000",6)

     

    What is your Datasource, SharePoint or excel.

    Try the above

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Verified answer
    v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@sayalides,

    Do you want to add zeroes to the start of the position id based on the number of the digits?

    I have a test on my side, please take a try as below.

     

    Text(Value(Concat(Filter(Split(First(Sort(USER2,PositionId,Descending)).PositionId,""),IsMatch(Result,Digit)),Result)),"[$-en-US]000000")

     

    Note: Please replace the correct parameters with your related column name.

    Annotation 2020-07-20 182050.png

    Best Regards,

    Qi

  • skd Profile Picture
    82 on at

    Hey @v-qiaqi-msft ,

    This is working but I want to patch the incremented value.By this formula I'm getting the last value from my back end of the positionId. I tried to set this value in a variable and then increment it but it as soon as I use this formula in Set function it gives and error saying "You can't use this property to set elsewhere in the app". Please let me know how can I increment the last value and then Push it.

  • skd Profile Picture
    82 on at

    hey @eka24 ,

    This is not working. 

  • eka24 Profile Picture
    20,925 on at

    Can you show what you did

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • skd Profile Picture
    82 on at

    Hey @eka24 ,

    I got the solution. I used the formula given by @v-qiaqi-msft  and I just made a few changes to it and hence got the solution. Thank you so much.

  • skd Profile Picture
    82 on at

    Hey @v-qiaqi-msft ,

     Thank you so much. The formula given by you is working I just made a few changes to get the value of PositionId auto-incremented. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard