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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Having trouble display...
Power Apps
Answered

Having trouble displaying the correct Office365Users.UserPhoto in a Gallery

(0) ShareShare
ReportReport
Posted on by 380

I have a Gallery that displays details of Field trips and the people that are on that trip - see screenshot1

I am trying to display the first person's photo only and so have had to create another Gallery (Gallery6) within the main gallery so I can pull out only the first person's name - the Items property for this Gallery is:

First(
Trim(
Split(
Title1.Text,
"  "
)
)

where Title1 is the label that holds the people's names - they are separated by 2 spaces.

Then the Image I have has the following Image properties: 

Office365Users.UserPhoto(
LookUp(
MyDetails,
Trim(Lower(Gallery6.Selected.Result)) in Lower(firstname & " " & surname),
email
)
)
where MyDetails is a Sharepoint list of all people that have ever used the app and contains their firstname, surname and email details.

 

I also have a searchbox (searchbox3) in the header section and it's referenced in the main Gallery's Items property which is:
SortByColumns(
With(
{
_preFilter: Filter(
Trips,
riskrating.Value = "Low" || riskrating.Value = "Medium"
)
},
Filter(
_preFilter,
searchbox_3.Text in officers || searchbox_3.Text in tripid || searchbox_3.Text in approver
)
),
"tripid")

 

When I don't put anything in the searchbox I get pictures displaying correctly but when I search on a person's name for example, I get unexpected results - screenshot2.  I think I am missing something obvious but can't quite figure it out

 

any help would be greatly appreciated and I hope I have explained my problem clearly

thanks

Categories:
I have the same question (0)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    --I see what you mean, Will see if I can make mine do same

     

  • bobgodin Profile Picture
    380 on at

    thanks @TheRobRush - interestingly enough it displays the first instance perfectly fine but then subsequent ones are incorrect - see screenshot3

     

    also if I search by tripid it works fine

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Just curious, how is the SPList laid out where the trip info is located. And is their name (I assume yes) present in the record that stores their trip data? If that is the case can you simplify your setup insomuch that you simply have the top gallery filter against the name you are looking for in the trip history name section, and a image control in that gallery that searches user details so you only see who was matched in the search as a gallery record at all?

  • bobgodin Profile Picture
    380 on at

    Yes their name is present in the Trips list but is part of a string (of names), for example:

    Andrew McDougall ; Sharon Marshall ; Tom Espinoza ; * * ; * * hence the reason for my 2nd Gallery as I'm trying to display the image for the first person in the string only....

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Ok so just as an example, here's a gallery where one of the items displays a string of character seperated by ; ; ; et al

    if you reference that string returned by initial search like so in your email lookup,

    First(Split(Subtitle1, "; ")).Result

    you should only ever get the first name as a return and should keep the next gallery items from lookign up any photo except the one of first name

    testme.PNG

    the subtitle1 referenced in my example above is the control that has the string of names shown in it

  • bobgodin Profile Picture
    380 on at

    thank you very much that is working and i can ditch the sub-Gallery now can't I?

    the only problem I have now is I realise I have some strings like this:

    David.E Cameron  Colin Farrawell  Robert Brazel  Paul Mitchell  Samuel Gregory - they have 2 spaces between them

    how can I accomodate these please Rob?

  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    Yes, you could get rid of the second gallery.

     

    as for the second issue i would do something like this

    testme2.PNG

    as you can see in this image i have two labels, one the names are seperated by ; and in the other double spaces.

     

    I then on the right have it returnign Rob Rush in both.

     

    The way you do this is like this

    Switch(
     CountRows(Filter(Split(Label3.Text,""),Result=";")),
     0, First(Split(Label3.Text, " ")).Result,
     First(Split(Label3.Text, "; ")).Result)

     

    it checks every character in your string, and if no ; is present splits them via a double space, else via the ;

  • bobgodin Profile Picture
    380 on at

    thank you so much @TheRobRush that worked a treat!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard