cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerbug
Frequent Visitor

Best way to clear/empty Data Table

Hi,

I have a button that gets data from the form and it makes some calculations & produces a set of rows and then patches multiple rows to Dataverse. If the patch is successful, I load the data into a Datatable on the form for the user to view what they just submitted.

I set the filter value for the data table using a variable on the button that does the Patch, this value is one of the textboxes on the form (ItemID)

Now I'm trying to put a clear button on the form to clear this datatable but I'm struggling to do this. I tried setting this filter variable to Blank() when the clear button is pressed, however this breaks the data loading to the datatable... And I'm wondering if I'm doing this in the wrong way.

What is the best way to clear a data table?

 

thanks

 

9 REPLIES 9
AVTS
Super User
Super User

 

 

Insert a Button with:

 

Clear(colTable)

 

 

RandyHayes
Super User
Super User

@powerbug 

Can you provide more details on your app (screenshots) including the controls in the screen as well as any formulas you currently are using that are not working?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
powerbug
Frequent Visitor

this doesn't work for the data table.

Invalid argument type (Control)  Expecting a Table value instead

I'm afraid I can't share screenshots as it's confidential (even the names of controls)
All I want to do is empty a datatable on the form by pressing a button and struggling to do this 

Lets say your current source of data is called TableWithData

Maybe have another Table called as EmptyTable with the same columns as TableWithData which will always be blank with only headers.

Use IF formula on the Datatable Items property, such that when you want to show empty records show EmptyTable, else TableWithData.

 

 

Edit: just to clarify, TableWithData and EmptyTable are Excel tables as an example. In your case could be something else.

AVTS
Super User
Super User

How about trying with flows ?

 

 

AVTS_0-1660650504805.png

 

 

 

powerbug
Frequent Visitor

Data table is a form control - so how could you empty it on runtime with flow, I'm confused. I'm talking about database tables

Hi Power to reproduce your issue we need to have the more details of your app as mentioned by RandyHayes.

 

Thank you . 

Let me explain in detail


I have a form, which takes some data from user. Then it makes a calculation, produces some rows and saves to database. 
The user wants to see what is  inserted, so I load all these to a data table on the form, called AddedRows
The Items property on AddedRows has this Filter('TABLE NAME',Field1=filter)
Filter is a variable I set on the button that adds rows to database
there's a ClearInput button. that clears the values on the form. I want this to clear the datatable as well. however when I update Filter in this button onclick it makes it mess up next time I load the table



Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,279)