Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

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

  • DarrenPlant Profile Picture
    77 on at
    Re: Add row to excel once

    @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 

  • efialttes Profile Picture
    14,756 on at
    Re: Add row to excel once

    @pennyland 

    Glad to see issue is solved.

    Thanx for the ThumbsUp and Happy Flowing!

     

  • pennyland Profile Picture
    192 on at
    Re: Add row to excel once

    THAT WORKED!!! Thank you SO MUCH!!

  • Verified answer
    efialttes Profile Picture
    14,756 on at
    Re: Add row to excel once

    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
    Re: Add row to excel once

    @efialttes 

     

     

     

     

  • efialttes Profile Picture
    14,756 on at
    Re: Add row to excel once

    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

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow