web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery Search of Offi...
Power Apps
Answered

Gallery Search of Office 365 Users by First Letter

(0) ShareShare
ReportReport
Posted on by 50

Hi Community,

 

Been banging my head against the wall with this one, and so far haven't come across anyone else who's either built something similar or come across the same issue from all the forum posts and YouTube videos I've watched.

 

I'm trying to create a Gallery search option using buttons that are grouped as: [A-C], [D-F], [G-I], [J-M], [N-P], [Q-Z] 

Each button has an OnSelect = Set(Var1,["A","B","C"]), or Set(Var1,["D","E","F"]) or Set(Var1,["G","H","I"]) ... you get the idea.

 

 

 

 

OnSelect = Set(Var1,["A","B","C"])

 

 

 

 

In my Gallery I have the following code:

 

 

 

 

Items = Sort(
 Filter(
 Office365Users.SearchUser(),AccountEnabled=true,
 Left(
 DisplayName,
 1
 ) in Var1.Value
 ),
 DisplayName,
 Ascending
)

 

 

 

 

 

However my Search results return some results from A-B... no C.

When I click the D-F button... nothing. No users returned.

When I click G-I button, 2 random users are returned. I know I have more users in my organisation between G and I.

 

I'm really stumped and very confused why no results / random 1-2 results are coming back for the other buttons.

 

Any ideas, oh wise wizards of the community?

Categories:
  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    My suggestion is for you to sort first by user and use a search. That dont way, I dont know, it does not seens like a good idea...

     

    https://www.youtube.com/watch?v=QhGV4AhCFRc 

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

  • mickyb23uk Profile Picture
    50 on at

    Thanks for your suggestion.

    However I know it must be possible based on a similar thread like this.

    Office365Users.SearchUser() in gallery duplicating... - Power Platform Community (microsoft.com)

     

    I just don't understand why not all my results are returning, should I do each button per letter perhaps?

  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    Maybe...

    You can always try with a switch instead..

    Switch( var;

                 1;

                  Filter( DATA_SOURCE, StartsWith( Name, "A" || "B" || "C"))

    ...

     

     

    Something like that

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

  • WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Hi @mickyb23uk ,

    Variables were not really intended to be used as Table (that is what collections are for) - try instead

    ClearCollect(col1,["A","B","C"])

    and then

    Sort(
     Filter(
     Office365Users.SearchUser(),
     AccountEnabled=true,
     Left(
     DisplayName,
     1
     ) in col.Value
     ),
     DisplayName
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Verified answer
    mickyb23uk Profile Picture
    50 on at

    I was able to get the desired result.

     

    I created 26 buttons from A-Z with OnSelect

    Set(Var_Letter, "A")

    Then in my gallery I set the following

    Filter(
     Search(
     Office365Users.SearchUser({top: 999}),
     Var_Letter,
     "DisplayName"
     ),
     StartsWith(
     DisplayName,
     Var_Letter
     ),
     AccountEnabled = true
    )

     And viola, I had a A-Z gallery.

    I also created an ALL button but simply setting OnSelect = Set(Var_Letter,"")

     

    Screenshot 2021-09-06 085545.jpg

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard