This Power Apps tutorial lets you know how to select multiple items in Power Apps Gallery Control.
As far as we know, there is currently no way to select several items simultaneously in the Power Apps Gallery. The user can only choose one item at a time.
Alternatively, we can use some different ways to achieve this. In this article, I will show you various ways to select multiple items in the Power Apps Gallery. Such as:
- Power Apps select multiple items in the gallery using the Collection
- Power Apps select multiple items in the gallery using the Checkbox control
How to Select Multiple Items in Power Apps Gallery Control
Refer to the below scenarios to select multiple items in the PowerApps Gallery.
Example – 1: [Using Power Apps Collection]
The screenshot below represents a Power Apps Gallery and a Text label control. When a user selects multiple items from the gallery, all the selected items will appear in the label control, as shown below.
To achieve it, follow the instructions below:
1. I have a SharePoint list named Employee Onboarding. This list has below fields with various records:
Column | Datatype |
---|---|
Employee ID | Number |
Employee Name | Title – Single line of text [I just renamed it to Employee Name] |
Department | Choice [HR, IT, FINANCE, MARKETING] |
Picture | Image |
2. In Power Apps, Connect the SharePoint list [Employee Onboarding] to the app.
3. insert a Gallery control and set its Items property as:
Items = 'Employee Onboarding'
4. Now, we will create a temporary collection in the Gallery’s OnSelect property:
OnSelect = If(
ThisItem.Title in colGallerySelected.Title,
Remove(
colGallerySelected,
ThisItem
),
Collect(
colGallerySelected,
ThisItem
)
)
Where,
- Title = SharePoint Column Name
- colGallerySelected = Temporary Collection Name
5. Select the gallery and set its TemplateFill property to the code below:
TemplateFill = If(
ThisItem.Title in colGallerySelected.Title,
RGBA(
118,
38,
242,
0.48
),
RGBA(
0,
0,
0,
0
)
)
Whenever a user selects items from the gallery, it will fill with a violet color, as shown below.
6. To display all the gallery selected items, add a Text label control and set its Text property as:
Text = Concat(
colGallerySelected,
Title,
Char(10)
)
All of the gallery items in the collection for the Title column are concatenated in the expression above. A new line [char(10)] separates each input.
This is how to select multiple items in the PowerApps gallery using the Collection.
Example – 2: [Using Power Apps Checkbox Control]
1. Let’s say there is a Gallery control in PowerApps. The gallery is populating with some names, as shown below.
2. Here, I would like to be able to select some gallery items at a time. In this case, I will use a Power Apps Checkbox control.
3. The screenshot below shows all the gallery control items that appear from a SharePoint List (Title column).
4. First, Select the gallery and click the edit pen icon. Then, insert a check box control (Insert -> Input -> Check box). Remove the Text from the Check box control.
5. Once you insert the check box into the gallery, the control will automatically appear in all items. apply the below formula on the Check box’s OnCheck property as:
OnCheck = Collect(
ItemCollection,
ThisItem.Title
)
Where,
- ItemCollection = Collection name
- Title = SharePoint field name that appears in the gallery
The above code specifies it will add the Title values to the collection once the check box is checked.
6. Next, under the OnUncheck property of the check box control, apply the code below:
OnUncheck = Remove(
ItemCollection,{Value: ThisItem.Title}
)
Where,
Remove = This function is used to remove a value from the collection.
When the check box is unchecked, then this will remove the title value that was added to the collection.
7. Next, suppose you want to visualize how the collection looks like when someone interacts with the checkboxes on the gallery. To show this, I will insert a Data table in Power Apps.
8. Select the Data table -> Go to Properties pane -> Click on Edit fields from Fields section -> + Add field -> Check the Value from check box-> Click on Add as shown below.
9. Then, go to the Items property of the data table and apply the below code:
Items = ItemCollection.Value
10. At last, Save and Preview the app. Check the desired item(s) from the gallery. At the same time, all the checked items will appear in the data table and the collection.
11. When you uncheck the item(s) from the gallery, then at the same time, the removed items will disappear from the data table.
This is another approach to select multiple items in the PowerApps gallery using the Checkbox control.
Conclusion
Hopefully, you better understand how to select multiple items in Power Apps Gallery Control. In this Power Apps tutorial, I have explained two various ways to PowerApps gallery multi select as:
- How to select multiple items in the Power Apps gallery using the Collection
- Select multiple items in the gallery using the Power Apps Checkbox control
Also, you may like some more Power Apps tutorials:
- Add New Row in Power Apps Gallery Control
- Sort Gallery by Person Column in Power Apps
- How to Sort Power Apps Gallery By ID
- Power Apps Filter Gallery By Year
- Power Apps Filter Gallery By Date
- 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