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 / Filter with Search and...
Power Apps
Answered

Filter with Search and Sorting Power App

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I created an app using data from CDS (the generic auto created one). I want to filter the list based on the status of the entity (Active) and if certain fields have data. Every time I try to put the Filter function in the below but no matter where I put it, I get the red lines of errors. Basically I need to know if a record is active and if there are 2 fields with data in them.

 

SortByColumns(Search([@Contacts], TextSearchBox1.Text, "gtwuk_membershipid","fullname","emailaddress1","telephone1"), "gtwuk_membershipid", If(SortDescending1, Descending, Ascending))

 

Any help would be great.

 

Thanks

 

 

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    With the 3 criteria, I think you should insert two additional comboboxes.

    In combobox1 items put: Contact.gtwuk_membershipid

     

    In combobox2 items put: 

    Contact.emailaddress1

     

    Then filter as follows:

    SortByColumns(Filter(Search([@Contacts], TextSearchBox1.Text,"fullname","telephone1")&& emailaddress1=Combobox2.Selected.emailaddress1&&gtwuk_membershipid=

    Combobox1.Selected.gtwuk_membershipid)),"gtwuk_membershipid", If(SortDescending1, Descending, Ascending))

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Community Power Platform Member Profile Picture
    on at

    @eka24 

    Thanks but after seeing this and thinking more about it, I really want to filter out the inactive records. When I try to do it with a Filter function I can't get it to work. 

    Basically I need Filter(Contacts, 'Status Reason (Contacts)'.Active) but I can't figure out how to get it in the given string and for it to work. Everything I have tried has failed. 

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Anonymous 

    I would take a different approach and create or modify some views using the entity's properties. (Middle screen shot and first screen shot) You can then select those views when you are creating the Items property of gallery.  PowerApps will automatically create the correct filter in the gallery.  The ability to create prefiltered and presorted views is one of the great advantages of CDS (and SQL too).Annotation 2020-05-13 122348.jpgAnnotation 2020-05-13 121131.jpgAnnotation 2020-05-13 121832.jpg

  • Community Power Platform Member Profile Picture
    on at

    @Drrickryp 

     

    Sorry still learning my way around PowerApps. Can I still use a search function (obviously a text input box) with a view?

     

    The primary purpose is to be able to lookup and edit contacts. I just don't want to query over a million contacts.

     

    Thanks

  • eka24 Profile Picture
    20,923 on at

    Can you show sample of your table with columns?

    If you are to filter for active only, you could try:

    Filter(Contacts, 'Status Reason (Contacts)'="Active")

    If it doesnt work, a sample of your table can help.

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Anonymous 

    Sure, Just wrap the search around the filtered dataset.  By using the entity's view you are already limiting the number of records that will need to be searched. This will really simplify writing the formula for the gallery too.  When CDS introduced this feature, I thought it was too good to be true. 

  • Community Power Platform Member Profile Picture
    on at

    @Drrickryp and @eka24 

     

    So this is what I have been trying and it is failing. I keep getting invalid arguments. 

    SortByColumns(
    Search(Filter(Contacts,'Status Reason (Contacts)' = "Active"), [@Contacts], TextSearchBox1.Text, "gtwuk_membershipid","fullname","emailaddress1","telephone1"), "gtwuk_membershipid", If(SortDescending1, Descending, Ascending))

    OR

    Search(Filter(Contacts, 'Contacts (Views)'.'Active Members'), [@Contacts], TextSearchBox1.Text, "gtwuk_membershipid","fullname","emailaddress1","telephone1"))

     

    I have a screenshot of some of the data we are using. It doesn't have the status listed but it is the generic status option set of active inactive. 

  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Not sure why you have [@Contacts] in  your formula.

     

    Search(
     Filter(
     Contacts, 'Contacts (Views)'.'Active Members'
     ), 
     TextSearchBox1.Text,
     "gtwuk_membershipid",
     "fullname" ,
     "emailaddress1", 
     "telephone1"
     )

     

     

  • Community Power Platform Member Profile Picture
    on at

    That works! Thank you

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 739 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 268

Last 30 days Overall leaderboard