cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mickyb23uk
Helper I
Helper I

Gallery Search of Office 365 Users by First Letter

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

5 REPLIES 5
Nogueira1306
Super User
Super User

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!

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?

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
Super User
Super User

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.

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

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,094)