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 / Excel calculations in ...
Power Automate
Answered

Excel calculations in Loop using desktop RPA

(0) ShareShare
ReportReport
Posted on by 45

We have an excel on which we are doing a calculations.  Last free row is fetched using the Get firstfree row / column option in desktop. The row variable is incremented by 2 after every write action.

 

The RPA is working well the only problem faced is the formulas are written 2x the total rows with data. So if my table has 10 rows, calculated field is written for 20. So if my table has 150 rows, calculated field is written for 300. 

 

Please assist to fix this. 

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Please share a screenshot of your flow. There is clearly something wrong with how you built it, but it is hard to tell without seeing it.

  • Nivedhana Profile Picture
    45 on at

    Nivedhana_0-1698395604807.pngNivedhana_1-1698395632758.png

    Hi @Agnius , thank you for prompt response. please find the screenshots.  Kindly assist to fix it.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Well, you are writing your formulas to two rows: %reefersport% and %reefersport-1%. And you are incrementing the %reefersport% variable by 2. So, naturally, you get formulas in two rows for each item in your data. That's the way it works. Not sure what your end goal there is, but if you only want to write to a single row for each item in your data, you should be incrementing your %reefersport% variable by 1 AND only writing to a single row at %reefersport% in every iteration.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Nivedhana Profile Picture
    45 on at

    For a certain business use, we need final data to be captured in alternate rows. That is why I incremented the write entry by 2. BTW, the data is written in 2 different columns as seen in below screenshot. Is there a better way to do it and achieve the same results?

     

    Nivedhana_0-1698399276255.png

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Well, if that is the case, instead of using a For each loop, use a normal Loop action, and iterate from 2 to %ExcelData.RowsCount%. And iterate by 2.

     

    It should look somewhat like this:

    Agnius_0-1698401800521.png

     

    You'll get a %LoopIndex% variable that you don't actually need to increment, because the Loop action will increment it for you. And then simply use that when writing your values.

     

    You can drop the If condition inside the loop, because it makes no sense to have it anyway. It will never be empty, because you're effectively checking for a data row to be empty. That can't happen, even if the cells are blank. But also, since you are alternating the rows, it doesn't make sense to do the check. 

     

    So, simply use a Loop and write all of those formulas the same way you're doing right now, but instead of the two indexes you're using, just use %LoopIndex%.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Nivedhana Profile Picture
    45 on at

    @Agnius Thank you, works when using the loop function. Can you also guide me how I can use If condition to check a value in excel. Ex- if the column contains ABC, formula should be A*B else A-B

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    This will be tricky, because you are incrementing your index by 2. So, this means you will only be checking every second row. If that's okay with you, you simply need an if statement that has %ExcelData[LoopIndex][ColumnIndex]% as the first operand (replace the ColumnIndex with an actual index for the column you want to check), contains as the operator, and "ABC" as the second operand.

     

    If you want to check every row, you need to change the way you loop and go back to doing a For each, but then not write into two rows at once, but instead have a condition that checks whether it should write something to the particular row or not.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 632

#2
Haque Profile Picture

Haque 458

#3
Valantis Profile Picture

Valantis 357

Last 30 days Overall leaderboard