Never wondered how to split gallery items in Power Apps? This blog describes how you can split a single gallery into multiple items in a secondary gallery. To be specific, the multiple selected items from the combo box control in the primary collection are split into multiple items in a secondary collection.
Consider a request app to request devices such as a desktop, laptop, tablet or phone. For each device you have the option to select accessories and quantity. In order to make it user-friendly for the end-user you are using the Combo box control for accessories and allowing the multiple selection property. However, you want to want to take that single item and split it into multiple items and save it in a secondary gallery. The total count of the multiple items depends on how many accessories were selected.
The app comprises of three collections, the primary, secondary and a temporary collection. The temporary collection is first used to save the split accessory items only and then using that collection the secondary collection is created.
In addition, we are using the DateAdd and Now functions to create the ID which is used to build relationship.
Here is a screenshot of the Save button. The button does four things:
- It first creates the ID value using Now and DateAdd and saves it to a variable
- Saves the data in the primary collections
- Splits the value from the Accessories and saves it as a comma separated value in a label. Data from that label is then split into a temporary collection.
- Takes values from the temporary collection and creates a secondary collection.
This video walks you through the entire process.
This is how you split gallery items in Power Apps. By splitting the data in Power Apps, you have already made it easier for future reporting purposes using Power BI.
Make sure to read my previous blog posts about Power Apps!