Are you facing any difficulties in incrementing a number in the Power Apps gallery? No need to worry! This Power Apps tutorial will teach how to increment number in the Power Apps gallery with a simple example.
Increment Number in Power Apps Gallery
Here, we will discuss how to increment a Text Box number values into your Gallery when you click on the “Button” control.
For example, In Power Apps, there are some records in the gallery like Input Details-1, Input Details-2, Input Details-3, Input Details-4, Input Details-5, and so on. Next, When a user deletes one item from the gallery suppose Details-3, the next item will be replaced in the deleted item place.
Refer to the below gif to understand better.
To work around this example, follow the below steps. Such as:
1. Open Power Apps with your respective Microsoft credentials -> Create Power Apps Blank Canvas app -> Select Power Apps Screen -> Insert a Text input control, a Button input [Add] and set Its OnSelect property as:
OnSelect = Collect(
InputCollection,
{
Name: "Input Details-" & CountRows(InputCollection) + 1,
TextBoxValue: txt_IncrementValues
}
)
Where,
- InputCollection = Power Apps collection name
- Name, TextBoxValue = Header of the collection
- CountRows = This function helps to count the total number of items or records in a gallery control.
- txt_IncrementValues = Text input control name
2. Next, insert the Gallery control and apply the collection on its Items property as:
Items = InputCollection
3. Then, within the gallery, insert a Trash icon to help delete the item. Apply the below code on the OnSelect property of the Trash icon:
OnSelect = Remove(
InputCollection,
ThisItem
);
Clear(colIncrementNumber);
ForAll(
InputCollection,
Collect(
colIncrementNumber,
{
Name: "Details-" & CountRows(colIncrementNumber) + 1,
TextBoxValue: txt_IncrementValues
}
)
);
ClearCollect(
InputCollection,
colIncrementNumber
)
Where,
- InputCollection = Power Apps source collection name
- colIncrementNumber = This is a new collection name
4. Once it is done, Save, Publish, and Preview the app. When a user adds any value from the text input control and clicks on the button control, it will increment the number in the gallery control as in the below screenshot.
This is how to work with the increment number in the Power Apps gallery.
Conclusion
From this Power Apps tutorial, we learned in detail information about how to increment a number in the Power Apps gallery with a simple example.
You may like:
- How to Sort Power Apps Gallery Alphabetically?
- How to Add Attachments in Power Apps Gallery?
- How to Delete SharePoint List Item from Power Apps Gallery?
- Delete SharePoint List Item from Power Apps Gallery
- Show Message If Gallery is Empty in Power Apps
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com