cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ecooney007
Advocate I
Advocate I

Power Automate - Excel - Update a row

Hey Guys,

I just wanted to add another post about updating a row in excel.  I read a bunch of stuff about this topic, and it was still a little confusing.

 

I then found this very helpful blog post by Ajith Madathil regarding get a row --> Retrieving a row from an Excel table using Power Automate (powerautomatetraining.co.uk) 

https://www.powerautomatetraining.co.uk/post/microsoft-flow-excel-get-row

 

Here are a few others that were also very helpful;

 

Solved: Help using Flow to update row in Excel - Power Platform Community (microsoft.com) 

https://powerusers.microsoft.com/t5/Connecting-To-Data/Help-using-Flow-to-update-row-in-Excel/td-p/200530 

 

Dynamically Updating Excel Rows - Power Platform Community (microsoft.com) 

https://powerusers.microsoft.com/t5/Building-Flows/Dynamically-Updating-Excel-Rows/td-p/77972 

 

Solved: How to use Flow to update a single Excel cell when... - Power Platform Community (microsoft.com) 

https://powerusers.microsoft.com/t5/Connecting-To-Data/How-to-use-Flow-to-update-a-single-Excel-cell-when-a-task-is/td-p/235564

 

Here is the Power Automate help page also;

 

Excel Online (Business) - Connectors | Microsoft Docs 

https://docs.microsoft.com/en-us/connectors/excelonlinebusiness/#update-a-row 

 

I wanted to kind of pull together all of the things found in these posts to go step by step in order to...

 

Update cells in a sheet that are on different rows

 

The MS FLOW I was trying to build was triggered by an intake form (FORMS - Microsoft) that has information related to a product that was brought back to the warehouse to be serviced. When the user hits submit on the form, the MS FLOW is triggered, a row is created in a TEAMS LIST, a new spreadsheet is created in a TEAMS FOLDER which is a copy of a template spreadsheet, and the information from the form need to populated at the top of the spreadsheet.

 

The top header info portion of the template spreadsheet is below. The yellow, empty cells are the ones I need to populate from

the MS FLOW after I create a copy of the template and rename it.

 

ecooney007_2-1620418904416.png

 

I really wasn't clear on what I needed to do to just update a cell in that top area.

 

After reading the posts above, it seemed like the MS FLOW Excel "Update a row" action was built more for updating rows in a 

tabular format, not necessarily picking and choosing a random cell like A:6 and updating it.  This makes sense as I'm sure, this would be

95 percent of what Power Automate users need.

 

Requirements

 

1. TABLE - I know that in order to update or work with any Excel data/cells from MS FLOW, the area surrounding that data in the spreadsheet MUST be in a "Table".

2. COLUMNS, ROWS - I also knew that the easiest way to get the data updated was to somehow have it in a more straight-forward column, row format.

3. UNIQUE KEY FOR EACH ROW - Within the column, row format, its recommended that the first value of the first column be unique,

so that the "Update a row" action can find the correct row you want and then update the column value for that row.

4. LOOP - From the examples I saw, I would also probably need to put the updates inside a LOOP Control Action for all the rows I needed to update.

 

With that being said, what I decided to do was to create a new Excel Sheet in the template called "Mappings" that would act as a hidden data mapping sheet, where I could do the updates, meet all the requirements above, and then just link those values back to the main spreadsheet. And again this data mapping table in this new sheet itself needs to be wrapped in a "Table".

 

So the new raw data mapper sheet looks like this;

 

ecooney007_3-1620420572749.png

 

I named the "FieldName" row values in the first cell with unique names that are the same names exact names on the main Sheet above.

These are fields that I want to update on that main sheet.

 

I then had to wrap the data mapper table inside a "Table" by selecting the data and clicking "Insert", "Table" in MS Excel. I also clicked on the "My table has headers" checkbox.

 

ecooney007_4-1620420951659.png

 

I then went to the main spreadsheet and created a cell link to each field I wanted updated on the "Mappings" sheet;

 

ecooney007_5-1620421277189.png

In other for the value of "Part Dealer:" which is in cell "E:5" above, I entered =IF(ISBLANK(Mappings!$B$2),"",Mappings!$B$2).

This pulls in the value from the "Mappings" sheet from cell $B$2 into the main sheet.

I repeated this for all the cells I want values updated in main sheet.

 

The "Mappings" sheet, when all fields are populated with data,' looks like;

 

ecooney007_6-1620422044717.png

 

The main sheet then looks like the following with all fields linked to the "Mappings" sheet;

 

ecooney007_7-1620422173649.png

 

When I save the template I just hide the "Mappings" sheet so the users don't need to worry about it.

 

So that takes care of the template spreadsheet and how the values can be update in main sheet.

But how do we make the MS FLOW "Update a row"?

 

The "Update a row" MS FLOW

 

In my MS FLOW to "Update a row", One of the first things I do after I add the form data to a list row, is create a copy of the template, I use the "Sharepoint" action "Get file content using path", you can see the path below refers to the specific "TEMPLATE NAME" in that folder;

 

ecooney007_9-1620423053713.png

 

I then create a new file which is a copy of the template, and rename it;

 

ecooney007_0-1620424266898.png

 

Now we start the process of updating a row in the new spreadsheet.

1. Create KEY VALUE OBJ after you add the item to the list - After the initial trigger in the FLOW, we Initialized a variable called "KEY VALUE OBJ" (which is type object) which will hold the same field names in the "FieldName" column from the "Mappings" Sheet, as well and the associated values from the form data. After you add the form data to a list, set values on "KEY VALUE OBJ" variable and inside the curly braces, you type in the "Mappings" sheet field names, and then add the values from the "Create item" action - the actual names of my fields from "Create item" are blurred out, but essentially you could name them the same as the field names if you wanted.  This variable will become important later as we loop through the rows.

 

ecooney007_2-1620425282827.png

 

 

2. Add action "List rows present in a table" - get a list of rows in the table we are going to update - this is the table in the "Mappings" sheet and I named it "Table2" in the spreadsheet.  Note - The "Id" variable in the "* File" field below is from the "Create file" action above.

 

ecooney007_1-1620424471408.png

 

3. Create the "Apply to each" LOOP action - what we do now is create the "Apply to each" LOOP action to each row in the "Mappings" sheet in our new spreadsheet (copied from the template).  You just take the "value" from the "List items in a spreadsheet" action and put that in the "*select an output from the previous steps" field;

 

ecooney007_0-1620425989449.png

 

 

4. To be continued...

 

 

 

 

 

 

 

 

 

 

 

 

1 REPLY 1
skibär
Frequent Visitor

Wow, I want to do pretty much exactly the same!

 

Could you finish this flow? Would you share some details?

Thanks!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,305)