cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
indhaa
Super User
Super User

Filter Gallery with Search bar or Status button

Hi,

 

I want User to use the search bar to filter and also want to filter if the form status buttons are clicked too, 

Below the two commands work perfectly separately but I'm unable to combined them.  How I'm doing it wrong?

 

SortByColumns(Filter([@WiFiAccess], SearchBox.Text in FullName || StartsWith(Organization,SearchBox.Text)), "ID", Descending)

 

SortByColumns(Filter(WiFiAccess,If(ButtonStatus<>"All",FormStatus=ButtonStatus,FormStatus="Pending Approval" || FormStatus="Pending Access"|| FormStatus="Rejected"|| FormStatus="Expired" && RevokedDate>=DateAdd(Today(),-10,Days))),"ID", Descending)

 

I tried to combined as below and it is not working. 

 

SortByColumns(Filter([@WiFiAccess], SearchBox.Text in FullName || StartsWith(Organization,SearchBox.Text) || (If(ButtonStatus<>"All" && !IsBlank(ButtonStatus),FormStatus=ButtonStatus,FormStatus="Pending Approval"||FormStatus="Pending Access"||FormStatus="Rejected"||FormStatus="Expired" && RevokedDate>=DateAdd(Today(),-10,Days))), "ID", Descending)

 

 

Any idea what I'm doing wrong. Very new to this

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
indhaa
Super User
Super User

@WarrenBelz  Seem the issue was because when text string search is empty, it is showing all the values. Now it is working perfectly. Couldn't have done without your input. I figured out when replying to you. 

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

Hi @indhaa,

I am not completely sure on your and/or sequence logic required, but brackets are essential to separate these out. I have done an example below with what I think you are trying to achieve.

SortByColumns(
   Filter(
      WiFiAccess, 
	  (
         SearchBox.Text in FullName || 
         StartsWith(Organization,SearchBox.Text
      ) &&
      If(
         ButtonStatus<>"All",
         FormStatus=ButtonStatus,
         (
            (
               FormStatus="Pending Approval" || 
               FormStatus="Pending Access"|| 
               FormStatus="Rejected"|| 
               FormStatus="Expired"
            ) &&
            RevokedDate >= 
            DateAdd(
               Today(),
               -10,
               Days
            )
         )			
      )
   ), 
   "ID", 
   Descending
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

This is how it will look like . By clicking the button or by search, user can filter 

indhaa_0-1611775805526.png

I'm trying the below code but still unable to correct it. I was trying with bracket before too but I'm doing something wrong. Can let me know what is wrong with my code?

 

SortByColumns

(Filter

(WiFiAccess, SearchBox.Text in FullName || StartsWith (Organization,SearchBox.Text) ||

If(ButtonStatus="All",FormStatus="Pending Approval"||FormStatus="Pending Access"||FormStatus="Rejected"||

(FormStatus="Expired" && RevokedDate>=DateAdd(Today(),-10,Days) )||

(FormStatus="Expired" && IsBlank(RevokedDate) ),

If(

ButtonStatus="Expired",

(FormStatus="Expired" && RevokedDate>=DateAdd(Today(),-10,Days) )||

(FormStatus="Expired" && IsBlank(RevokedDate) ),

FormStatus=ButtonStatus

)

)

),"ID",  Descending)

@indhaa ,

I do not know the logic you are trying to achieve (only you do), but when you are coding, set it out like the below and see if the flow of and/or is what you want - you will go in circles with brackets if you do not.

SortByColumns(
   Filter(
      WiFiAccess, 
      SearchBox.Text in FullName || 
      StartsWith(Organization,SearchBox.Text) ||
      If(
         ButtonStatus="All",
         FormStatus="Pending Approval" ||
         FormStatus="Pending Access" ||
         FormStatus="Rejected" ||
         (
            FormStatus="Expired" && 
            RevokedDate>=DateAdd(Today(),-10,Days)
         ) ||
         (
            FormStatus="Expired" && 
            IsBlank(RevokedDate
         ),                  //logic break here - Button Status is not "All"
         If(
            ButtonStatus="Expired",
            FormStatus="Expired" && 
            (
               RevokedDate>=DateAdd(Today(),-10,Days) || 
               IsBlank(RevokedDate)
            ),                 //logic break here - Button Status is not "Expired"
            FormStatus=ButtonStatus
         )
      )
   ),
   "ID",  
   Descending
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

 

Thanks for trying to help, Still it is not working. It is still the same issue. When I clicked on the Status buttons nothing happens but when I enter in the search bar it is filtering and when I then click on the button it is filtering with what in the search bar and selected filter for the button, It is showing for example in the search bar I typed " Text" and clicked " pending approval" button. It is prompting all record with "Text" irrelevant of the status and all record with pending approval status.  So I must still be missing "&&" sign somewhere .

 

What I want is when I clicked the button, it to prompt the result. Also to prompt for the search bar. And when I clicked the button it to show the search bar filter only for those matching status.  Going to check if an "&&" helps. Any thoughts? 

@indhaa ,

It might be a bracket at the top

SortByColumns(
   Filter(
      WiFiAccess, 
      (   
         SearchBox.Text in FullName || 
         StartsWith(Organization,SearchBox.Text)
      ) ||
      If(
         ButtonStatus="All",
         FormStatus="Pending Approval" ||
         FormStatus="Pending Access" ||
         FormStatus="Rejected" ||
         (
            FormStatus="Expired" && 
            RevokedDate>=DateAdd(Today(),-10,Days)
         ) ||
         (
            FormStatus="Expired" && 
            IsBlank(RevokedDate
         ),                  //logic break here - Button Status is not "All"
         If(
            ButtonStatus="Expired",
            FormStatus="Expired" && 
            (
               RevokedDate>=DateAdd(Today(),-10,Days) || 
               IsBlank(RevokedDate)
            ),                 //logic break here - Button Status is not "Expired"
            FormStatus=ButtonStatus
         )
      )
   ),
   "ID",  
   Descending
)

This is very difficult to do without having the app to see if the results are what you need as the code syntax is valid.

Have you tried pulling it apart and getting one function working as you want, then adding back in the others one at a time?

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks a lot for your help but still the same. I test all the time by breaking the code to make sure all the parts are working as it should. The code was break as below and it works fine separately. Issue comes when I try to combined it.

 

SortByColumns(Filter(WiFiAccess, SearchBox.Text in FullName || StartsWith(Organization,SearchBox.Text)),

"ID", Descending)

 

SortByColumns

 (Filter

    (WiFiAccess,

       If(

             ButtonStatus="All",

                FormStatus="Pending Approval" ||

                FormStatus="Pending Access"     ||

                FormStatus="Rejected"                ||

                (

                  FormStatus="Expired" && (RevokedDate>=DateAdd(Today(),-10,Days) ||

                  IsBlank(RevokedDate))

                ),

                   If(

                          ButtonStatus="Expired",

                          FormStatus="Expired" && (RevokedDate>=DateAdd(Today(),-10,Days) ||

                          IsBlank(RevokedDate)),

                         FormStatus=ButtonStatus

                      )

            )

     ),

"ID", Descending

)


I tried to test without all the nested "If" and still the same results. Maybe the two filters doesn't works together? I tried putting the bracket at the top and vice versa but still same results.

 

SortByColumns

 (Filter

   (WiFiAccess,

      SearchBox.Text in FullName || StartsWith (Organization,SearchBox.Text) || FormStatus=ButtonStatus

   ),"ID",  Descending

)

 

This is the results I'm getting

 1. Without any text in the search, the status button doesn't work. (Maybe it is filtering for empty text string?)

 2. The search bar works

 3. If I press the status button with text string in the search, it is filtering for what is in the search bar AND filtering for forms that is true for button status.

 

I would like the gallery to work as such that;

  1. With an empty text string in the search bar, the status button to prompt for forms that is true for button status

  2. Search Bar to work separately

  3. To Search for text string which prompt true for button status.  meaning an AND condition

 

Get what I'm trying to do. Perhaps I need to do bring the results in another way? Maybe I need to count the empty search bar which is bringing the incorrect result? 

 

  

indhaa
Super User
Super User

@WarrenBelz  Seem the issue was because when text string search is empty, it is showing all the values. Now it is working perfectly. Couldn't have done without your input. I figured out when replying to you. 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,380)