PowerApps - display distinct items in gallery
My data in SharePoint list:
Project: Single line text
Meeting/Forum: Choice
Status: Choice
Meeting Date: Date
In PowerApps, to display distinct items in a gallery based on certain columns like text, numeric, boolean and date/time, you can use the GroupBy function. It does not support a choice field. This function groups your data by the specified columns and allows you to display it without duplicates.
To support choice field, we need to convert the choice field to a text field. Use the below code to convert your choice field to text as shown below:
ClearCollect(SPMeetings, AddColumns(Meetings, NewMeetingType, 'Meeting/Forum'.Value));
This adds a new text column "NewMeetingType" in the collection "SPMeetings". This text column can be used in GroupBy for our specific requirement.
How to use GroupBy
The below picture shows multiple groupby function implementation- Insert a Gallery: Add a new gallery control to your screen to serve as the main container.
- Add a Label: Inside the main gallery, insert a label control.
- Set Label Text: Configure the text property of the label to
NewMeetingType
. - Insert an Inner Gallery: Within the main gallery, add another gallery control.
- Configure Inner Gallery Items: Set the items property of the inner gallery to
ThisItem.GroupedData
. - Insert Labels in Inner Gallery: Add three label controls inside the inner gallery.
- Assign Properties to Labels: Set the text properties of these labels to the respective fields you wish to display from
ThisItem.GroupedData
.
This structured approach will help you organize the elements within your galleries and ensure that the data is displayed correctly in PowerApps.
Let me know your thoughts in comments. Thank you.
Post a Comment