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

How to use an if statement for the items of the gallery and addcolumn to that gallery

I have a text box  (DataCardValue48) and a gallery (Gallery1).  I have th gallery connected to office365users.  My main app is connected to SQL and trying to create a dynamic people field like sharepoint list people column but has to save a single line of text.  I am trying  to add a column to a gallery to show if it is selected so I can change the template fill to show that it is selected to be saved back as my single line of text.

DataCard update:

If(IsBlank(Gallery1.Selected),DataCardValue48.Text,varDesignLeader)

Textbox default:  

If(IsBlank(varDesignLeader),Parent.Default,varDesignLeader)

 

I have two different formulas for the items of the gallery, One for the add column the other for the Search o365 users. 

AddColumns(ForAll(Office365Users.SearchUser({searchTerm:DataCardValue48.Text,top:10}),{DisplayName:DisplayName}),"CustomSelected",false)

and 

If(Len(DataCardValue48.Text)>0,Sort(Filter(Office365Users.SearchUser({searchTerm:DataCardValue48.Text}),Len(GivenName)>0&&AccountEnabled),GivenName,Ascending),Filter(Office365Users.SearchUser({searchTerm:"zzzz"}),Len(GivenName)>0))

Gallery1 OnSelect: 

Set(varDesignLeader,ThisItem.DisplayName)

I cannot figure out how to combine them.  Any Ideas?

1 REPLY 1
Highlighted
Community Support
Community Support

Re: How to use an if statement for the items of the gallery and addcolumn to that gallery

Hi @mandy4514 ,

Do you want to addcoulumns to the result of Search o365 users formula?
If so, try this formula:

AddColumns(ForAll(
If(Len(DataCardValue48.Text)>0,
Sort(Filter(Office365Users.SearchUser({searchTermSmiley Very HappyataCardValue48.Text}),
Len(GivenName)>0&&AccountEnabled),GivenName,Ascending),
Filter(Office365Users.SearchUser({searchTerm:"zzzz"}),Len(GivenName)>0)),
{DisplayNameSmiley Very HappyisplayName}
),
"CustomSelected",false)

  //replace the table inside forall function with the result of Search o365 users formula.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,087)