Showing results for 
Search instead for 
Did you mean: 
Not applicable

Delete all rows in a table

I'm new to PA/Flow and very confused by this-deleting rows (no conditions, just empty the entire table) seems like a pretty obvious objective. I am trying to delete all rows in a table when a flow is triggered.


(Yes, my table is definitely an excel table, not a range! 🙂 )


The flow is marked on Power Automate as running successfully (which I believe confirms the flow is running and that there are no apparent errors, so that's good at least) but the table rows aren't deleted. 


The flow is triggered when a Sharepoint list is modified. 

The destination is an excel spreadsheet, which must be emptied/have all rows removed when this list is modified. 


(I am assuming that in order to delete a row, a condition must be met (ie, there is no way to simply delete rows without performing a logical test).


When an item is created or modified (in the specified Sharepoint site address and list name):


List rows present in a table: 

Location: Sharepoint name containing Excel file

Library: Sharepoint folder containing Excel file

File: Excel file

Table: Excel table


Apply to each VALUE:

Excel column 2 ('ID_Number') is equal to Excel column 2 ('ID_Number').  (Note that I am simply looking for a test that will always evaluate to true, and I see no reason why this wouldn't do so). 



Delete a Row:

Location: Sharepoint name containing Excel file

Library: Sharepoint folder containing Excel file

File: Excel file

Table: Excel table 

Key column: ID_Number  (I honestly wasn't sure what to put here. I presume that the key column is important when performing logical tests, since it is checked for its value??)

Key value: ID_Number (Again, I am not sure of the relevance of the key value here. Presume this is a value that is tested for, eg greater than/less than?)



Note: the above test did not work, so just to confirm that the logical test was not evaluating as false, I duplicated the 'YES' code into 'NO':


If NO:

Delete a Row:

Location: Sharepoint name containing Excel file

Library: Sharepoint folder containing Excel file

File: Excel file

Table: Excel table

Key column: ID_Number  

Key value: ID_Number 


No joy. The flow appears to run without errors, but the table retains all of its values (all rows should be deleted). 


Could someone please assist? 


Much appreciated-thanks. 


Community Champion
Community Champion

Hi @Anonymous 


It looks ok, at least what you wrote.


Are you defining the name of the table, the key column and the key correctly? Probably it runs correctly but, since it can't match the key with the one in Excel, it doesn't delete anything.


Also be careful with types. You may have a String or a Float that, when compared, may be considered different than your value's type in SharePoint.


If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.


Not applicable

Thanks for the response. I think the 'key column' and 'key value' fields are the issue. But if the intention is to remove existing rows regardless of their currently contained value, then how do I go about removing the rows using the 'delete a row' method? Or is there an alternative approach? 


It does not matter whether the row / field is blank, contains 'aaa' or '123' or any other value-I just want to delete the row 🙂



Continued Contributor
Continued Contributor

@Anonymous if you are still having issues, could you provide screenshots of your flow?


You shouldn't have to run through a condition in order to delete the rows. Your question is asked and answered here  but basically you can use the List Rows Present in a Table as you had, then nest "Delete a row" in an "Apply to each" loop.


Make sure you're using Dynamic Content that matches the value you choose for your key column so that as the "Apply to Each" loops through the rows in your spreadsheet, you're matching the value in the key column to itself (thus always evaluating as "true") and prompting the Flow to delete the row.


It doesn't matter what field you choose as your "key column", but you need to make sure that the "Dynamic Content" that you select for your "key value" is the same field.


See example screenshot below:

Delete a Row.png


I hope this helps, let me know if you have any questions.



Frequent Visitor

I'm using this approach for a scheduled Excel update, but I find one of the slowest steps is deleting the 1000+ rows in a table so I can replace them with new data. Is there a quicker way to empty the table than listing all current rows and then recursively deleting them?



Did you find a way to do this quickly and efficiently.

I too have about 1000 rows to delete (whole table contents actually)... so I can populate with new contents.

I'm doing this from Power BI --> Power Automate

- David

Helper I
Helper I

I would have thought a standard action to clear table should be created.

I don't suppose there's any update to this?

Frequent Visitor

On your "Apply to each" where you delete the rows, click the "..." and select setting. Turn on Concurrency Control and crank up the Degree of Parallelism. You'll get a tenfold or greater speed boost.


Having said that, I don't know what any downsides would be to using this method. I use it myself and haven't had any issues that I know about.

Helper I
Helper I

The downsides are:


Maximum of 5000 rows


High utilisation of flows, therefore risk of daily limits being reached


Time taken to delete 5,000 rows takes hours, whereas a delete table contents option would mitigate all of the above

Frequent Visitor

Thank you for the clarification! I was sure there must be some downside.

Frequent Visitor

Hi Joel,


Hope you suggested using Delete table in the Transform query using Power Automate since Execute SQL query is not allowed..But if we use it in Transform Query, rows are getting deleted even if we recreate again.. Did u face that problem.It would be grateful if you can suggest.

Advocate I
Advocate I

I was also very annoyed by the slow performance of the "apply-to-each"+"delete"-loop and decided to use a workaround via the "Run script"-action. With the following script I managed to reduce the runtime from 30 minutes to 30 seconds. Maybe it's helpful to some of you as well:

function main(workbook: ExcelScript.Workbook) {
   let sheet = workbook.getTable("YOUR_SHEETNAME_HERE");
   // the following line gets the first table object from the list of all tables in your sheet, in my case it's the only one
   let table = sheet.getRange().getCell(0,0).getTables()[0];
   let tableRange = table.getRangeBetweenHeaderAndTotal();
   // errorhandling if the table is already empty
   if (tableRange.getRowCount() == 1) {
      console.log("nothing to delete");
   else {
     // delete all the cells in the table data range, the table range is then reset automatically



FYI, I also tried the table method for row deletion:

//delete all rows from index 0
table.deleteRowsAt(0, tableRange.getRowCount())

This was very slow as well and resulted in a script timeout.


Hope this helps some of you, best wishes


Helpful resources

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (1,847)