I have a gallery of users. which is filtered using the A-Z buttons under the search. I want the user to press a letter and employees whose first name begins with that letter to be displayed. The OnSelect of the A-Z buttons set a variable with the corresponding letter.
Employees are being displayed correctly when varSelectedFilter = "All", but when a letter button is pressed the gallery contains duplicate entries (see screen shot example).
The searchTerm will populated with the letter of the button pressed
Office365Users.SearchUser({searchTerm: varSelectedFilter})
The searchTerm property in Office365Users applies to: display name, given name, surname, mail, mail nickname, and user principal name. I want to display just those employees where first name starts with the selected letter, so I use StartsWith(DisplayName, varSelectedFilter) to filter.
Items property of Gallery1
If(
varSelectedFilter="All",
Sort(Sort(Filter(Office365Users.SearchUser({searchTerm: txt_SearchBox.Text, top:999}),!IsBlank(Mail)),Surname, Ascending),GivenName,Ascending),
Sort(Sort(Filter(Office365Users.SearchUser({searchTerm:varSelectedFilter,top:500}),!IsBlank(Mail),StartsWith(DisplayName,varSelectedFilter)),Surname, Ascending),GivenName,Ascending)
)
The interface

Maybe this isn't the best strategy. If so I'd appreciate any help pointing me in the right direction.