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 / Dynamically filter a g...
Power Apps
Unanswered

Dynamically filter a gallery based on a sharepoint linked column

(0) ShareShare
ReportReport
Posted on by 27

Hi

I have a gallery in my powerapp I'd like to dynamically filter both the field to search and the value of that search based on context variables passed through from a button on another screen. The field that I want to filter by is, in this case, a linked column in my sharepoint list datasource.

 

the button code, which seems to work fine, is 

Navigate(InteractionsBrowseScreen,ScreenTransition.None, {InteractionsFilterValue:DataCardValue17.Text, InteractionsFilterField:"Organisation.Value"})

 

The InteractionsFilterValue is the default value of the search textbox in the gallery (TextSearchBox1).

 

The data field of the gallery is

 

SortByColumns(Filter([@Test_Interactions], StartsWith(InteractionsFilterField, TextSearchBox1.Text)), "Created", If(SortDescending1, Descending, Ascending))

 

Which I think should work, but it returns no rows.

 

If I hard-set the filter field rather than using the variable, it works, although I do get a delegation warning

SortByColumns(Filter([@Test_Interactions], StartsWith(Organisation.Value, TextSearchBox1.Text)), "Created", If(SortDescending1, Descending, Ascending))

 

How can I do this without creating duplicate screens and galleries with different data fields?

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Lee123 

    You cannot reference fields by name in PowerApps.  You are trying to pass the field name and then use that as a referenced field.  This will not work and your filter criteria will evaluate to false and you will have no values.

     

    What you can do is use the name in your filter as a condition:

    SortByColumns(
     Filter(Test_Interactions, 
     Switch(InteractionsFilterField,
     "Organisation.Value", StartsWith(Organisation.Value, TextSearchBox1.Text),
     "someothercolumn", StartsWith(someOtherColumn, TextSearchBox1.Text)
     )
     ),
     "Created", 
     If(SortDescending1, Descending, Ascending)
    )

     

    I hope this is helpful for you.

     

  • Lee123 Profile Picture
    27 on at

    Thanks Randy that got me a lot closer, but ended up rewriting the filter as

     

    SortByColumns(

        Filter([@Test_Interactions], ( IsBlank(TextSearchBox1.Text) || StartsWith(Organisation.Value, TextSearchBox1.Text) || TextSearchBox1.Text in Names.Value) )

          ,

           "Created", If(SortDescending1, Descending, Ascending))

     

    and abandoning the InteractionsFilterField.

     

    It almost works as I want it to, but the 'Names' field from the sharepoint list is a multiple value column that is also a lookup column. With the current code I get exact match working fine - so I can enter 'john smith' and get the hits but not 'john'

     

    Any ideas what I could do about that? I tried using Search instead of filter but it won't work with either of the lookup columns, the single value 'organisation' or the multiple value 'names'. Works fine with non-lookup columns.

     

    Search( Test_Interactions, TextSearchBox1.Text, "Organisation.Value", "Names.Value" )

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Lee123 

    You'll not be able to use the Search function on a multi-value lookup.  You can use the In operator for this.

        Filter(    

            Search( Test_Interactions, TextSearchBox1.Text, "Organisation.Value")

            TextSearchBox1.Text in Names.Value

        )

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard