cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mandy4514
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
v-yutliu-msft
Community Support
Community Support

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
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (4,800)