Simple screen with a table and delete button. what is the best way to delete a row from that table based on the date column(Oldest Date) in the table?
And here it is in action:
Hope this helps!
Thank you. This is exactly what I need.
HI @aj -
Is there any way to add an automation to delete the top 10 rows in a Table? I am trying to create an archive of sorts, but I only want to keep an archived record of the last 500 records. So I have set up an automation to run if =COUNT(Archive[Date Archived])>500. Now I am trying to figure out how to specify which rows to delete (the top 10 rows of the table in this case).
@Jared, if you click Run Options within the Delete row action block (see screenshot), you can specify multiple rows to delete using a filter. In your case, you will likely want to add an ID or Number column to your Archive table. Each time you add a new record to Archive, put the value =MAX(Archive[ID]) + 1 in the ID column of the new record. Then your filter in the Delete row action block would be =FILTER(Archive, "Archive[ID] < MIN(Archive[ID]) + 10"). Place that formula in the textbox labeled Run the step for these rows.
If you don't want to add an ID column to your table, you could filter the 10 oldest records using your Date Archived column, but the formula would be more complex. It would be something like: =FILTER(Archive, "COUNT(FILTER(Archive, %)) < 10", "Archive[Date Archived] < THISROW()[Date Archived]"). No guarantees that last formula is correct. It's a little complicated with the nested FILTER's, and I didn't test it.
Thanks for your insight on this. What I ended up doing was using a filter to delete the oldest batch of records by archive date once the archive reached a certain capacity. I'll post the function below.
=filter(archive,"archive[date archived]=MIN(Archive[Date Archived])")
Nice, that's even simpler!