cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hughrmarks
Level: Powered On

Clearing out my Datasource

I use Patch to drive data into my datasource, which is an Excel table.   I pull that data back in to different PowerApps screens.   I want to set up a button on one of my screens that clears all of that data out of that table.   Any suggestions?

6 REPLIES 6
Sienna
Level 10

Re: Clearing out my Datasource

Easiest way is to collect all rows from main datasource into a collection and then use that collection to remove that rows

Put in your button OnSelect property

 

ClearCollect(RemoveCollection, MainDatasourceName); Remove(ManiDatasourceName,RemoveCollection)

 

Change the MainDatasourceName with the name of your excel datasource

JRaasumaa
Level 10

Re: Clearing out my Datasource


@hughrmarkswrote:

I use Patch to drive data into my datasource, which is an Excel table.   I pull that data back in to different PowerApps screens.   I want to set up a button on one of my screens that clears all of that data out of that table.   Any suggestions?


If you want to clear the excel table you'll need to use a Remove or RemoveIf function

https://docs.microsoft.com/en-us/powerapps/functions/function-remove-removeif

 

If all you want to do is clear the collected table information in PowerApps, it should be just as easy as doing a Clear(Collection)

 

If you want to collect fresh info you can do a ClearCollect(Collection, 'DataSource')

 

See the Clear, Collect, CleaCollect functions here:

 

https://docs.microsoft.com/en-us/powerapps/functions/function-clear-collect-clearcollect

 

hughrmarks
Level: Powered On

Re: Clearing out my Datasource

Well it worked but......   The first column in my table is "ID" numbered 1, 2, 3...   I use this to reference the rest of the data.   When I cleared out everything it cleared that too - never thought about that.   Now I'll have to reset those numbers every time.   Can I reference a Row in Excel instead?   I won't have to reset my table all that often but I'm hoping there's a way around this.

Sienna
Level 10

Re: Clearing out my Datasource

@hughrmarks

So why are you trying to reset the table then?

You can also reset the table and look for a highest id in a table where your IDs are stored and continue adding new row to the table you reset with highest id+1

hughrmarks
Level: Powered On

Re: Clearing out my Datasource

@Sienna   I pull data from the table to populate some screens.   When I want to start over, I need to clear that data.   I'm sure it would be much easier to use a collection for this but I'm finding it very difficult to pull specific tems out of a collection.   I suppose I should learn more about them.   Thank you for your help.

Super User
Super User

Re: Clearing out my Datasource

Collection does sound like a better idea. I have a couple videos that may help at least get you closer. PowerApps Collections and More PowerApps Collections.

 

Maybe instead of troubleshooting this temp table in Excel, which isn't a good idea anyway, let's try troubleshooting your issues with collections. 🙂 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,371)