cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PrasoonSur
Frequent Visitor

Incremental Serial Number

I have an excel online table in which each row are uniquely identified by a serial number. A portion of the table is displayed below:

Power Automate Doubt.PNG

Using power automate, I want to fetch the highest Serial Number (in this case, 21), add 1 to it (then 22), and then use the new serial number to be added in a new row of the same excel table.

 

So the next time I run the flow, the highest will be 22, then add 1 to it, and then the new Sl no will be 23, and so on.

 

I'm fairly new to power automate, I tried to get the answer from existing questions, but somehow it wasn't working for me. Could someone pls help me out with the same example given above? Your help will be much appreciated.

 

If you need any extra information, please let me know.

 

@Mister_Shaik |  @ScottShearer |  @jinivthakkar |  @Expiscornovus |  @ekarim2020 

1 ACCEPTED SOLUTION

Accepted Solutions
fchopo
Super User
Super User

Hi @PrasoonSur 

You could do something like the following:

serial-number.png

1) List the rows present in the Excel Table, ordered by SerialNumber column in descending order.

2) Get the first item of the previous action, and read the SerialNumber column value (21 in your sample), using the following expression:

first(outputs('List_rows_present_in_a_table')?['body/value'])?['SerialNumber']

Following, you should add 1 to the result and use it to create a new row in excel.

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

2 REPLIES 2
fchopo
Super User
Super User

Hi @PrasoonSur 

You could do something like the following:

serial-number.png

1) List the rows present in the Excel Table, ordered by SerialNumber column in descending order.

2) Get the first item of the previous action, and read the SerialNumber column value (21 in your sample), using the following expression:

first(outputs('List_rows_present_in_a_table')?['body/value'])?['SerialNumber']

Following, you should add 1 to the result and use it to create a new row in excel.

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Hi @fchopo ,

Thanks for the help!!

I tried out the solution, which works like a charm in some cases but sometimes not (if entries are done fast) 

 

I have added the same expression you provided, then converted it to an integer and then composed an add function to add 1 to the current highest number.

 

Power Automate Doubt 2.PNG

Compose : 

first(outputs('List_rows_present_in_a_table')?['body/value'])?['Sl_no']
 
Compose 2: 
int(outputs('Compose'))
 
Compose 3: 
add(1,outputs('Compose_2'))

 

 

It worked the first time, and it is working when I give some time in between to add next entry. But if I add the lines fast, it gives the previous solution;  so I assume I need to refresh the workbook before doing the above calculations. Is there any way to do that?

 

Anyways you had provided the solution to my initial question, so I have accepted it as a solution. Much appreciated!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (2,437)