03-12-2024 08:00 AM
Template workaround for "When an Excel row is created", "When an Excel row is modified", and/or "When an Excel row is deleted" triggers.
Limitations
• Initially only set up for Excel tables of less than 100,000 records and less than 100MB contents. Version b allows for more than 100,000 records, but still has a 100MB contents limit.
• Each record must be unique. So each record must have a column or combination of columns that is unique & not empty for every single row. In other words, it must include a primary key.
• Every time a new row is added, it must include the primary key column(s) value(s).
• For large tables, the initial set-up may have a 10+ minute delay between the last edits & running whatever actions one adds for the rest of the flow. Version b does include a set-up that is almost twice as fast, but even that will still see a several minute delay after the last edit when the selected Excel file is 10s of thousands of rows.
Initial table
Table edits
Flow run for the 50,000 record table
Example email message with HTML tables for each filtered set of records
HTML table styling: https://ryanmaclean365.com/2020/01/29/power-automate-html-table-styling/
Go to the bottom of the post, download the zip file, go to the page for your flows, and select the legacy import option
Upload the import, change the connections, & select the import button
Select the Open Flow link & delete the initial placeholder value compose action
Switch to your desktop, create a text file on your desktop, input something that follows a JSON structure, go to save the file, add a .json file extension while changing the Save as type to All files & preferably give the file a name that refers to the target Excel workbook name & table name
Go to the same SharePoint library as your Excel workbook with the Excel table you are creating the flow for & upload the new JSON file. Make sure it is set up in a place where no one else will delete or alter it.
In the list for the SharePoint library select the Add column option, select the Show or hide columns option, then select to show the ID column & Apply the changes. Once the ID column is showing, go to the row with the Excel workbook you are creating this for & copy the file row ID.
Switch back to the flow. Open the 1st trigger action "When an item or file is modified" & choose the site & document library for your Excel file.
Then go to the 3 dots on the 1st trigger action "When an item or file is modified", go to the Settings, select the +Add button under Trigger Conditions, input the ID copied for the file row into the expression & paste the expression into the Trigger Conditions & select the Done button
@equals(triggerOutputs()?['body/ID'], InsertIdNumberHere)
Open the 1st Scope of the flow "Only let the flow run if all users stopped editing for a set time", Open the "Get file properties" action, and select the Site address & SharePoint Library Name for your Excel workbook
Then open the "Settings" action & input the name(s) of the column(s) that form a unique key for every row. So the names for the column or combination of columns with values that are unique for every row in the table
Then go to the Scope below that "Read the Excel table and only let the flow run if no edits during read" and in the Excel List rows & Get file properties 2 actions select the Excel Location, Document Library, File, Table, Site Address, & Library Name
If you are using version b, then you will need to input the Excel file & table references in two places:
Then go to the next Scope "Load previous table version copy before updating to the most recent table copy" and in the Get file & Update file actions select the Site Address, File Path, Site Address, & Site Address for the JSON file you loaded into the SharePoint library. This will hold a JSON array copy of the Excel table for the flow runs.
Save & run the flow once so any existing data in your Excel table is recorded in the previous table version JSON file. This will prevent any later actions you add from running for every existing row the 1st time the flow is triggered. By running it once without added actions, it will correctly run your added actions for only the edited rows the 1st time it is triggered later.
That is all the set-up for the template that will run whenever anything in the Excel workbook is modified and that will output different sets (arrays) of the Created records, Modified records & Deleted records. From here you can use the example Apply to each loops & example compose action inputs to set up what actions you want the flow to run for newly created records, for modified records, and/or for deleted records. In the example Apply to each loops the From field is filled with the array Body of the appropriate filter array action for the Created, Modified, or Deleted records and within the loop you can reference any of the record column values with the provided expression by inputting your chosen Apply to each loop name & inputting your chosen column name.
items('Insert_Loop_Name_Here')?['InsertColumnNameHere']
Also if you do not plan to ever use one of the Created, Modified, or Deleted outputs, then you can delete both the filter array action for those records & the associated Apply to each loop
And if you only want the flow actions to run when changes are made to specific columns, you can set the Excel List rows table read to only Select the primary key column & those specific columns to check for changes as described here.
Version B:
Version B replaces the single 100,000 pagination Excel List rows connector with a bit more complicated set-up that determines a rough approximation of the total rows in the table, then loads several 5000 row batches from the table with concurrency/in parallel and then combines all those 5000 row batches into a single JSON array output similar to the output of the standard 100,000 pagination Excel list rows connector.
Reasons to use Version B:
If you need a faster flow with less time between the last Excel table edits & the triggering of flow actions for those edits.
If you want to use this on an Excel table with more than 100,000 rows that is still below 100MB total content.
If you have a lower level Microsoft / Office365 license and only have a maximum pagination / Excel connector load of 5000.
If you have any trouble importing through the standard import method, see this post to import through a solution package.
Thanks for any feedback,
Please subscribe to my YouTube channel (https://youtube.com/@tylerkolota?si=uEGKko1U8D29CJ86).
And reach out on LinkedIn (https://www.linkedin.com/in/kolota/) if you want to hire me to consult or build more custom Microsoft solutions for you.
watch?v=85QAQ-tb1M8
For learning purpose, could you please or any one explain why you used these actions,
1- in the Do until action, it count the rows and compare it to one, why is that ? is this necessary ? and the loop action next to it why we need it?
@SiyamandRashid I don't know why you have an Apply to each appearing there. I don't have one in the original template there. You should be able to drag the Get file properties action down outside the loop & delete the loop.
@SiyamandRashid
Ahh, you are on the version 1.1b of the flow for the faster triggering of the flow / faster excel reads. In that version it is meant to get a rough count of the number of rows in the Excel table so the following action can read multiple batches of rows in at the same time to speed up the table read.
You may want to use the normal version 1.1 for easier understanding.
Hey there @takolota - I got this to work! Great tutorial. I have read through the comments and I can't seem to find an answer to my question. So I have a table that is essentially a calendar. Each column is a day of the year. My rows are the sites that I manage as a regional manager. If I get notified via email that a site is going to have down time or no staffed, I enter that time frame into the cell for that date and that site. The email I get is 365 columns and it's very small. Is there any way that I can just get the date (column), site (row), and time (cell) emailed? The rows will never be added or deleted because none of my sites are going away nor will I add any more sites. I'm only interested in the modify because I am constantly adding times for holidays and non-staffed sites.
Does this make sense?
It should already only return the relevant sites (rows). I’m not sure there is any simple way to identify & return only the changed columns.
Is there a reason you have the table set up with 365 days? Why not model the data as a table of just site name, date, & time and have new rows for each time added?
@takolota - Thank you so much for your prompt reply. I'm working on this assignment and it has me all out of sorts. the plot thickens here. Maybe it might be better if I can email you directly and we can work through it or if you want to continue to use this forum it's ok with me as well. 2 discoveries that I made while trying to automate this:
1. I have some VB code in the background that is attempting to log any cell changes to another sheet so I can get a summary of who changed what and when in a very high level - still trying to work out the kinks on this. Therefore this is a macro-enabled excel spreadsheet. Power automate does not like my .xlsm file type. At least it does not display when I try to search for it.
2. This is also a collaborative spreadsheet, meaning that it is shared across with other people contributing to this workbook. I would like them to also get the power automate notifications as well. I'm thinking that they are going to have to do the same thing that I did. I also have some users open this in the web version of excel and others open this in the desktop app. My question is, once I have my flow configured, I should be able to copy it and send out, correct? The location of the spreadsheet is going to be the same and they already have permission to the sheet. If they make changes in EITHER the web version or desktop app, it shouldn't matter, correct. the spreadsheet is still hosted in SharePoint
Below is a sample of how I have my spreadsheet laid out. This just gives a nice visual representation for the users. The locations always stay the same and the date is it's own column. Now I'm open to changing the formatting, but this seemed to be the easiest way to represent this data. If you or others in this community have suggestions on how to better lay this out, I'm interested. Right now, I have the managers of the sites come into this sheet and highlight the cell green and define a time of when the site is either going to be down or non-staffed.
Since I manage multiple sites, I have to come in here daily and check to see who updated what. This is where I found you. If I could get an email with the table formatting that alerted me of the updates, I wouldn't have to take the time to check the sheet. The other issue that I run into is that with O365, there is no developer tab in the web version of excel, it is only a automate tab menu which is odd. I tried inserting vb code into here and it does not work at all. So I'm trying to better understand how to convert vb code to this automated script tab.
Any help or guidance on any topics would be appreciated!!!
techstudent36
@techstudent36
Having each user copy & set up the flow so they can receive emails sounds prohibitive. It would risk sometimes missing an email send if two people were editing at the same time, but you could get the modified by email from the trigger & send any notifications to that email address. You could reduce or remove the delay action to minimize the times people editing the file at the same time would miss a notification.
To try to slim down the HTML table for the notifications, you could do some hack-ish stuff where on each modified row you use some string( ) & split( ) expressions and some Filter array actions between the previous table version rows & the new table version rows to try to narrow things down to only the cells that have changed. I don't see an easier way to deal with this given the unconventional way you have your data set up.
Frankly you would need to pay me to help build out any kind of custom solution for such a set-up. You can try posing the same questions to the community for more support.
Thanks,
Dear @takolota
I want to run the flow only when a new records have been add, how to to that please?
Regards
@SiyamandRashid Only put actions in an Apply to each on the Created Filter array body output & you don’t need to run anything after the Modified or Deleted filters so you may get rid of them.
Dear @takolota thank you for the reply, but as I'm new these things is too advance for me, could you please put some screenshots for me?