cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
afjm
Frequent Visitor

Lookup function inside of a search function

I have two data tables which are somewhat connected but technically separate. I have one data table which has team names and usernames of supporting contacts. The other data table has usernames of supporting contacts & those contacts information. I am attempting to do a lookup inside of a search function in order to sort a gallery but am getting an error that the search is expecting text.

 

Is it possible to do a lookup inside of a search function like as follows?

 

Search(CachedTeam, SearchFieldTeam.Text, LookUp(CachedContact, Title = "PriContactUsername", FirstName))

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @afjm,

Based on the formula that you provided, I think you have some misunderstanding in Search function in PowerApps.

The third argument of the Search function is required to provide a column name, but the LookUp formula that you provided would return a Text value rather than a column name.

More details about the Search function, please check the following article:

Search function

If you want to filter your CachedTeam records based on the result the LookUp formula returns, I think the Filter function could achieve your needs. Please take a try to modify your formula as below:

Filter(
CachedTeam,
SearchFieldTeam.Text in LookUp(CachedContact, Title = "PriContactUsername", FirstName)
)

then check if the issue is solved.

The above formula may cause a Delegation issue, in order to get rid of this issue, please take a try with the following workaround:

Set the OnVisible property of the first screen of your app to following:

ClearCollect(RecordsCollection, CachedTeam)

Modify your Filter formula as below:

Filter(
RecordsCollection,
SearchFieldTeam.Text in LookUp(CachedContact, Title = "PriContactUsername", FirstName)
)

 

Best regards,

Kris

 

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

View solution in original post

1 REPLY 1
v-xida-msft
Community Support
Community Support

Hi @afjm,

Based on the formula that you provided, I think you have some misunderstanding in Search function in PowerApps.

The third argument of the Search function is required to provide a column name, but the LookUp formula that you provided would return a Text value rather than a column name.

More details about the Search function, please check the following article:

Search function

If you want to filter your CachedTeam records based on the result the LookUp formula returns, I think the Filter function could achieve your needs. Please take a try to modify your formula as below:

Filter(
CachedTeam,
SearchFieldTeam.Text in LookUp(CachedContact, Title = "PriContactUsername", FirstName)
)

then check if the issue is solved.

The above formula may cause a Delegation issue, in order to get rid of this issue, please take a try with the following workaround:

Set the OnVisible property of the first screen of your app to following:

ClearCollect(RecordsCollection, CachedTeam)

Modify your Filter formula as below:

Filter(
RecordsCollection,
SearchFieldTeam.Text in LookUp(CachedContact, Title = "PriContactUsername", FirstName)
)

 

Best regards,

Kris

 

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

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (39,090)