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

Incremental list based on the value in the last row of the first column

Hi all

 

I have created an automated flow that's triggered when a new response is received for a Microsoft Form.
It adds a new row to an existing Excel sheet that's stored in Onedrive.

 

However, before I add the row to the table, I would like to add an incremental ID based on the last RFP ID that exists in the spreadsheet . 

 

Flow.PNG


This cannot be entered manually using Forms/Excel because

a) Access to the Excel sheet is limited to 2 users

b) Forms are used by multiple users who will have no way to track (apart from asking the 2 users) on what was the last RFP ID

 

 

Capture 3.PNG

 

So far, I'm able to get the last row and get its output in Compose but unable to extract RFP ID and increment it to be added in the newly created record. I also note that RFP_ID will probably be required to be trimmed/converted to another format to be allowed to be incremented?

 

The expression used in Compose is last(body('List_rows_present_in_a_table')?['value'])

 

 

Any help will be greatly appreciated!

 
1 ACCEPTED SOLUTION

Accepted Solutions

@Ash_R 

last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'] should get you the specific column of the last row.  Test that first.
 
If that works, we want to split that on the underscore and grab everything after:
 
Split(last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'],'_')[1]     (the [1] is saying 'grab the second element of the array we created by splitting the value).  Test that next.
 
Now, we want to convince Flow/Power Automate that the thing is a number, so we wrap the whole thing in an INT()...so: 
 
INT(Split(last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'],'_')[1])  Test that part.
 
And finally, we want to add 1 to get the next increment.
 
ADD(Int(Split(last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'],'_')[1]),1)
 
Putting all that in your Compose, should give you the desired result.  We can do that with less Functions, if you want, too.  Happy to help either way.
 
Keep us posted.
-Ed-
 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

 
 

View solution in original post

4 REPLIES 4

@Ash_R 

last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'] should get you the specific column of the last row.  Test that first.
 
If that works, we want to split that on the underscore and grab everything after:
 
Split(last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'],'_')[1]     (the [1] is saying 'grab the second element of the array we created by splitting the value).  Test that next.
 
Now, we want to convince Flow/Power Automate that the thing is a number, so we wrap the whole thing in an INT()...so: 
 
INT(Split(last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'],'_')[1])  Test that part.
 
And finally, we want to add 1 to get the next increment.
 
ADD(Int(Split(last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'],'_')[1]),1)
 
Putting all that in your Compose, should give you the desired result.  We can do that with less Functions, if you want, too.  Happy to help either way.
 
Keep us posted.
-Ed-
 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

 
 

View solution in original post

Ash_R
Frequent Visitor

Thanks @edgonzales!

 

This solution works!

 

It'll be definitely interesting to know the alternative that you suggested i.e. by using less functions
(if you have the time, of course) 😀😋

@Ash_R 

Of course!  It really only saves the last part, and also means setting up a variable.

 

In the beginning, you would initialize an integer variable, and then set it to be this part:   INT(Split(last(body('List_rows_present_in_a_table')?['value'])['RPF_ID'],'_')[1]

 

Then you could add the action step "Increment Variable" to add 1.

 

Not super helpful, but is a little bit closer to the 'no-code' stuff.

-Ed-

 

 

Ash_R
Frequent Visitor

Thanks for helping out @edgonzales , greatly appreciated!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,453)