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 / Update Excel if it exi...
Power Automate
Answered

Update Excel if it exist else create a new row where both source and destination are excel in a SharePoint

(0) ShareShare
ReportReport
Posted on by 42

Hello experts,

 

I need help with my flow.

I have an excel source file in a SharePoint where I need to first filter 2 columns, 1st is the ID column where I only get non blank and 2nd is the status column where I only get Pending, Approved and Not Approved.
After filtering, I have to compare the filtered result to the destination excel which is also in the same SharePoint, all of those that matches will have to be updated and all of those no match will be created as new into the destination file. After which, all of those Pending in status in the destination will generate a notification email for each row. 

I cant get my flow working.

Any help will be greatly appreciated. 

heyjay_0-1700733290857.png

 

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

    Hi , @heyjay 

    According to your description, you want to update the second the Excel file based on the first Excel and if the row do not exist based on the “ID” and “status” column , you want to add the column in the second Excel file.

    This is my test Excel file, for your need ,we need to add an Index column(unique column) in the second Excel file due to the “Update column” action need a unique column if exits the duplicate value.

    Solved: Update multiple rows in "Update a row" action with... - Power Platform Community (microsoft.com)

     

    And this is my test Excel file:

    vyueyunmsft_0-1701074225741.png

     

     

    This is my flow:

    vyueyunmsft_1-1701074225745.png

     

     

    (1)The first three actions:

    vyueyunmsft_2-1701074225747.png

     

    @and( not(equals(item()?['ID'], string(''))),contains(createArray('Pending','Approved','Not Approved'), item()?['status']))

     

    (2)The Apply to each action:

    vyueyunmsft_3-1701074225751.png

     

     

     

    [Note] The Index is the unique column I created in Excel file. As above said "due to the “Update column” action need a unique column if exits the duplicate value."

    You could create this column manually or you could use the Office script:
    Run Office Scripts with Power Automate - Office Scripts | Microsoft Learn

    And this is the code:
    function main(workbook: ExcelScript.Workbook) {

      let selectedSheet = workbook.getActiveWorksheet();

      let tbl = selectedSheet.getTable("Table2")

      tbl.addColumn(0).setName("Index")

      let rowCount = tbl.getRowCount()+1;

      let firstColumnRange = selectedSheet.getUsedRange().getAddress().split("!")[1].split(":")[0].split('')[0]

      let firstRowRange = selectedSheet.getUsedRange().getAddress().split("!")[1].split(":")[0].split('')[1]

      selectedSheet.getRange(`${firstColumnRange}${Number(firstRowRange) + 1}`).setValue("1");

      selectedSheet.getRange(`${firstColumnRange}${Number(firstRowRange)+1}`).autoFill(`${firstColumnRange}${Number(firstRowRange) + 1}:${firstColumnRange}${Number(firstRowRange)+rowCount-1}`, ExcelScript.AutoFillType.fillSeries);

    }

     

     

     


    Best Regards,

    Yueyun Zhang

     

     

  • heyjay Profile Picture
    42 on at

    Hello @v-yueyun-msft ,

     

    This is brilliant, so you are! Thank you for helping! This has solved my problem.

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!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 250 Super User 2026 Season 1

#2
Expiscornovus Profile Picture

Expiscornovus 222 Most Valuable Professional

#3
Haque Profile Picture

Haque 174

Last 30 days Overall leaderboard