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 Automate
Unanswered

Add row to excel once

(0) ShareShare
ReportReport
Posted on by 192

I have a flow that compares a form response with an excel spreadsheet. If the value exists in the spreadsheet already, the flow updates that record. Which works fine.

If the value does nOT exist in the spreadsheet, the flow adds a new record to the spreadsheet wiht the values submitted in the form.

The problem is that it does so multiple times, not just the one time as expected.

In fact it does so as many times as there are existing rows in my table!!

 

How can I add the row to the table only once?  

 

flow_adding_rows_to_excel.png

Categories:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at

    Hi

    Let's assume you have 7 rows in your excel sheet, and a new forms response is received.

    Your current flow iterates 7 times (row by row) due to the Apply to each.

    In each iteration your flow performs an evaluation. If such evaluation succeeds, the flow updates the row under evaluation on that iteration. If such evaluation fails, the flow creates a new row on that iteration.

    If no row matches your evaluation, then 7 new rows are added.

    If 1 row matches your evaluation, the row is updated once, and 6 new rows are added.

     

    I would follow a different approach.

    First, initialize a boolean variable before your apply to each, lets call it 'matchingRow', you should set its value to false.

    Next, inside your apply to each, under the true condition branch, you currently have 'Update a row'. Plase add 'Set variable', select 'matchingRow' and assign it true value.

    NExt, remove 'Add a row into a table' from the false condition branch.

    Now, just after your 'Apply to each', you should add a new condition to evaluate content of variable 'matchingRow'.

    On its false branch, add the action 'Add a row into a table'.

     

    Flow_DisastrousLoop.png

     

    There are probably more efficient ways to implement your requirements, but this approach should work.

    Hope this helps

     

  • pennyland Profile Picture
    192 on at

    @efialttes 

     

     

     

     

  • Verified answer
    efialttes Profile Picture
    14,756 on at

    Hi

    Move the second condition OUT of the 'Apply to each' and try again. In your current flow, it was added inside by mistake, so the result is the same as you got with your initial flow version

    Hope this helps

  • pennyland Profile Picture
    192 on at

    THAT WORKED!!! Thank you SO MUCH!!

  • efialttes Profile Picture
    14,756 on at

    @pennyland 

    Glad to see issue is solved.

    Thanx for the ThumbsUp and Happy Flowing!

     

  • DarrenPlant Profile Picture
    77 on at

    @pennyland I understand this query is 2 years old but I am having same issue.  I get how to do this except I want to understand your first condition to continue building my flow.

     

    My flow is user fills in MS Form, it writes to an excel sheet.  Based on region (field in the excel), the idea is to send email to appropriate person.  I am currently facing the row being written twice to the excel and my 'apply to each' is going haywire and sending multiple emails (one email per row in excel, not just one based on the new row).

     

    cc: @efialttes 

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard