web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Syncing Excel to Postgres
Power Automate
Suggested Answer

Syncing Excel to Postgres

(1) ShareShare
ReportReport
Posted on by 2
I'm blanking on how to do this properly. I have a "List rows present in a table" to get all the rows from Excel, then a "Get rows" from a Postgresql DB. I want to do two things:
  1. For each row in the Excel table, check if that row exists in Postgresql. If it does, update it
  2. If it does not exist, insert the row into postgres. 
How would I go about doing an "Apply to each row in Excel" > "Check if it exists in postgres" > If yes update, if no create.
Categories:
I have the same question (0)
  • Suggested answer
    trice602 Profile Picture
    15,404 Super User 2025 Season 2 on at
    Hi,
     
    I think this framework will help you keep going.  Essentially in your for each loop (from excel body/values), you want to check if the row exists in Postgres by some unique ID.  Then you are either updating a row or inserting a row.  
     
    I have a handful of flows like this and I know the general framework will work for you.  This is common also if you are updating or inserting in Excel or Lists, etc.
     
    Note the condition is exactly what you would use in your scenario, just an example.
     
    Alternatively, I think you could also use "Get Row" instead of "Get Rows" and just check in the Row exists and then check if the output is empty, if true, insert else update.
     
     

    ------------------------------------------------

     

     

    ⭐ If this was helpful, please like and mark as a verified answer to help others find this too!

     

     

    Always glad to help! 💯💯💯💯💯

     

    Tom

     

    Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn

  • lbendlin Profile Picture
    8,479 Super User 2025 Season 2 on at
    Does your PostGreSQL table have a Primary Key constraint?  If yes then you can brute force it by first attempting an INSERT and then when it fails run the UPDATE.  Or use IF NOT EXISTS etc.
     
    You will also want to think about speeding this up.  Instead of doing RBAR (row by agonizing row) send the entire Excel Table to PostGres and then use a Stored Procedure there to UPSERT the data.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard