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 Automate / Formula to change ID f...
Power Automate
Answered

Formula to change ID format to a new UniqueID column (1 to 0001)

(0) ShareShare
ReportReport
Posted on by

Hi all,

I have this SharePoint list, now I want to create the prefix '0000' for the UniqueID from ID.

Example: 

If the ID is 1, I want the Unique ID to become 0001

If the ID is 10, UniqueID becomes 0010,

If the ID is 100, UniqueID becomes 0100,

If the ID is 1000, UniqueID becomes 1000,

 

I did some research about this, I tried these 2 formulas that I already put inside the SharePoint list column formula for calculated

=TEXT(ID, "0000")

=CONCATENATE([Field value],REPT("0",MAX(0,4-LEN(ID))),ID)

 

But somehow the formula keeps on changing when I refresh or create a new item. Sometimes it will appear 0009 instead of 9, but sometimes it will appear 0000, sometimes it will appear 0, and sometimes It will appear 9 every time I refresh

 

I also use this calculation 

=RIGHT(CONCATENATE("0000",ID),4)

 

But as you can see, it will appear 0000 (bottom)

nraindmia_0-1711334744982.png

 

Do you have any other way on how to solve it?

 

thanks!

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

    Hi @nraindmia ,

     

    Considering the limitations of SharePoint, the ID field is automatically generated and cannot be directly used in a calculated column.

     

    I suggest you create a text-type UniqueID column, then use power automate to update it. I've made a test for your reference:

    1\My SP list

    vbofengmsft_0-1711336044494.png

    2\The flow

    vbofengmsft_2-1711336285156.png

     

    3\Result

    vbofengmsft_1-1711336215530.png

     

    Best Regards,

    Bof

     

  • nraindmia Profile Picture
    on at

    Hi @v-bofeng-msft ,

     

    Appear this error. The uniqueID is a text column right?

    nraindmia_0-1711336812540.png

     

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @nraindmia ,

     

    The uniqueID is a text column right?

     

    Yes. Could you please show me your flow?

     

    Best Regards,

    Bof

  • Verified answer
    SanmeshG Profile Picture
    1,947 Moderator on at

    Hi @nraindmia  ,

     

    You can get this by just applying this JSON formatting to the calculated column and you should be good. However this doesn't return the value displayed in the view when you read list items from flow.

     

    {
     "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
     "elmType": "div",
     "txtContent": "=if([$ID] > 999, [$ID], if([$ID] >= 100, '0' + [$ID], if([$ID] >= 10, '00' + [$ID], if([$ID] <= 9, '000' + [$ID], ''))))"
    }

    SanmeshG_1-1711343358746.png

     

    If this helps , do give this a thumbs up and mark this as a solution.

     

    Thanks,

    Sanmesh

  • nraindmia Profile Picture
    on at

    Hi @SanmeshG ,

    Your code is working. Thanks a lot !

     

    nraindmia_0-1711357029956.png

     

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 Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard