How to use Collect, Clear, Count rows Functions in Canvas App
Scenario: Here to Use these functions ive created a Feedback Screen, there i will collect the feedback from users with Collect function and will clear the feedback entries with clear function and I will show how many entries have entered with Count row’s function.
Note: Here I’m Not using any Dataverse to store the feed, I’m storing the feedback in a collect
High level resolution steps
1. I’ve Used Gallery to show the collected data using Collect Function
2. With Count rows function I’ve showed entries of feedback
3. With Clear function I’ve cleared the Collection
Detailed resolution steps
Step 1: Insert a Text input for Name of the User and Another Text input for Feedback, change the feedback text input mode into Multiline.
Add a Button and label it as Submit to submit the feedback

Step 2: Now Insert a Button and label it as Submit. On Select property of Submit button add the following Code
Copy button for small sizeIf(
IsBlank(Textinputname.Text) || IsBlank(Textinputfeedback.Text),
Notify("Please fill in both fields.", NotificationType.Error),
Collect(FeedbackCollection, {Name: Textinputname.Text, Feedback: Textinputfeedback.Text, Timestamp: Now()});
Reset(Textinputname);
Reset(Textinputfeedback)
)
Explanation of Code:
When we click the Submit Button the code checks if both input fields (TextinputName and TextinputFeedback) are filled or not.
- If either is empty: It shows an error notification (“Please fill in both fields”).
- If both are filled: It saves the data (Name, Feedback, and Timestamp) to FeedbackCollection and clears the input fields.
Step 3: Insert a Gallery and on Items property of Gallery give collectionname here in this scenario we are using “FeedbackCollection”.

Now as there are no feedback entries its showing “0”
Step 4: Insert a Button and label it as Clear Feedback, Now on Select Property of Clear feedback button give this code, this will clear the collection
Clear(FeedbackCollection); |
Step 5: Now to Show how many Feedback entries have been Entered, insert a Label Rename it as lbl_TotalFeedbackEntries and On Text property of it give this code
“Total Feedback Entries: ” & CountRows(FeedbackCollection) |
Explanation of Code:
1. “Total Feedback Entries: “
a. This is a text string that serves as a label or prefix.
2. CountRows(FeedbackCollection)
a. CountRows is a function that returns the total number of rows (entries) in the specified collection, in this case, FeedbackCollection.
3. Concatenation (&)
a. The & operator concatenates the text string and the result of the CountRows function into a single string.
Output
When you enter any Feedback, it will store in a collection and it will show how many entries have been entered, and with clear feedback button we can clear all feedback entries stored in the collection.

