cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RodrigoCastelli
Helper IV
Helper IV

Keep Filter after go to Gallery

Hello,

 

I have a gallery that has 3 filters applied to it. When the user clicks on an item of the gallery and uses the command "back" after that, he loses the filters previosly applied.

 

How could i change it?

 

Thanks and Best regards,

2 ACCEPTED SOLUTIONS

Accepted Solutions

HI @RodrigoCastelli ,

I cannot quite line up the values in relation to the drop-down results as there is some inconsistency in your code, but the easiest syntax to do what you are trying is as below.

With(
   {
      wDD1:DropDown1.Selected.Result;
      wDD2:DropDown2.Selected.Result;
      wDD3:DropDown3.Selected.Result;
      wDD4:Filt_Status.Selected.Result
   },
   SortByColumns(
      Search(
         Filter(
            MYLIST;
            (wDD1 = "All" || Estrela = wDD1) &&
            (wDD2 = "All" || 'Cat.' = wDD2) &&
            (wDD3 = "All" || Lider = wDD3) &&
            (wDD4 = "All" || Status = wDD4)
         );
         TextInput2.Text;
         "Op";
         "Client"
      );
      "Estrela";
      Descending;
      "Client";
      Ascending
   )
)  

 

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.

View solution in original post

Hi @RodrigoCastelli ,

I have tested the concept here and it works fine. Have you put a label on the same screen with varDD1 in the Text and ensured the value is set?

View solution in original post

16 REPLIES 16
RandyHayes
Super User
Super User

@RodrigoCastelli 

You'll need to provide more details on how you are currently filtering and where that filtering is being set initially.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
emseki
Community Support
Community Support

Hello,

You can use global variables to save filter conditions like "Set(Category, Dropdown1.Selected)" via OnChange property of Dropdown1 for example, and use it for filter conditions. Global variables won't be cleared with navigating screens.

Hi @RandyHayes ,

 

Sorry for the lack of information. This is my screen and the code:

 

Power Apps.png

 

This code is applied in the Function "Items" in the gallery.

 

SortByColumns(Search(If(DropDown1.Selected.Result = "All" And DropDown2.Selected.Result = "All" And DropDown3.Selected.Result = "All";MYLIST;DropDown1.Selected.Result = "All" And DropDown2.Selected.Result <> "All" And DropDown3Selected.Result = "All";Filter(MYLIST;Status = DropDown2.Selected.Result);DropDown1.Selected.Result <> "All" And DropDown3.Selected.Result = "All" And DropDown3.Selected.Result = "All";Filter(MYLIST';Estrela = DropDown1.Selected.Result);DropDown1.Selected.Result <> "All" And DropDown3.Selected.Result <> "All" And DropDown2.Selected.Result = "All";Filter(MYLIST;Status = DropDown3.Selected.Result And Estrela = DropDown1.Selected.Result);DropDown1.Selected.Result = "All" And DropDown3.Selected.Result = "All" And DropDown2.Selected.Result <> "All";Filter(MYLIST;Líder = DropDown3.Selected.Result);DropDown1.Selected.Result <> "All" And DropDown2.Selected.Result = "All" And DropDown3.Selected.Result <> "All";Filter(MYLIST;Líder = DropDown3.Selected.Result And 'Cat.' = DropDown1.Selected.Result);DropDown1.Selected.Result = "All" And DropDown2.Selected.Result <> "All" And DropDown3.Selected.Result <> "All";Filter(MYLIST;Líder = DropDown3.Selected.Result And Status = Filt_Status.Selected.Result);Filt_Star.Selected.Result <> "All" And DropDown2.Selected.Result <> "All" And DropDown3.Selected.Result <> "All";Filter(MYLIST;Líder = DropDown3.Selected.Result And Status = DropDown2.Selected.Result And Estrela = DropDown1.Selected.Result));TextInput2.Text;"Op";"Client");"Estrela";Descending;"Client";Ascending)

 

Do i need to provide more information?

 

Best regards,

Hi @emseki ,

 

I don't quite undestand the concept you mentioned could you give some example?

 

My filter code is applied to the Function "Items", as the code below.

 

SortByColumns(Search(If(DropDown1.Selected.Result = "All" And DropDown2.Selected.Result = "All" And DropDown3.Selected.Result = "All";MYLIST;DropDown1.Selected.Result = "All" And DropDown2.Selected.Result <> "All" And DropDown3Selected.Result = "All";Filter(MYLIST;Status = DropDown2.Selected.Result);DropDown1.Selected.Result <> "All" And DropDown3.Selected.Result = "All" And DropDown3.Selected.Result = "All";Filter(MYLIST';Estrela = DropDown1.Selected.Result);DropDown1.Selected.Result <> "All" And DropDown3.Selected.Result <> "All" And DropDown2.Selected.Result = "All";Filter(MYLIST;Status = DropDown3.Selected.Result And Estrela = DropDown1.Selected.Result);DropDown1.Selected.Result = "All" And DropDown3.Selected.Result = "All" And DropDown2.Selected.Result <> "All";Filter(MYLIST;Líder = DropDown3.Selected.Result);DropDown1.Selected.Result <> "All" And DropDown2.Selected.Result = "All" And DropDown3.Selected.Result <> "All";Filter(MYLIST;Líder = DropDown3.Selected.Result And 'Cat.' = DropDown1.Selected.Result);DropDown1.Selected.Result = "All" And DropDown2.Selected.Result <> "All" And DropDown3.Selected.Result <> "All";Filter(MYLIST;Líder = DropDown3.Selected.Result And Status = Filt_Status.Selected.Result);Filt_Star.Selected.Result <> "All" And DropDown2.Selected.Result <> "All" And DropDown3.Selected.Result <> "All";Filter(MYLIST;Líder = DropDown3.Selected.Result And Status = DropDown2.Selected.Result And Estrela = DropDown1.Selected.Result));TextInput2.Text;"Op";"Client");"Estrela";Descending;"Client";Ascending)

 

How could i apply this idea?

 

Best regards,

HI @RodrigoCastelli ,

I cannot quite line up the values in relation to the drop-down results as there is some inconsistency in your code, but the easiest syntax to do what you are trying is as below.

With(
   {
      wDD1:DropDown1.Selected.Result;
      wDD2:DropDown2.Selected.Result;
      wDD3:DropDown3.Selected.Result;
      wDD4:Filt_Status.Selected.Result
   },
   SortByColumns(
      Search(
         Filter(
            MYLIST;
            (wDD1 = "All" || Estrela = wDD1) &&
            (wDD2 = "All" || 'Cat.' = wDD2) &&
            (wDD3 = "All" || Lider = wDD3) &&
            (wDD4 = "All" || Status = wDD4)
         );
         TextInput2.Text;
         "Op";
         "Client"
      );
      "Estrela";
      Descending;
      "Client";
      Ascending
   )
)  

 

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.

View solution in original post

Hello @WarrenBelz ,

 

Thanks for the improved code.

 

Infortunatelly it does not work, i have received a message that the Search operation is invalid.

 

The problem apparently is in this part below, because when i removed the variable wDD = "All" from all fields it worked.

 

(wDD1 = "All" || Estrela = wDD1) &&
(wDD2 = "All" || 'Cat.' = wDD2) &&
(wDD3 = "All" || Lider = wDD3) &&
(wDD4 = "All" || Status = wDD4)

 

Besides that, backing to the main subject of the topic, it is posible to keep my filter information after change screens in that situation?

 

Best regards,

Hi @RodrigoCastelli ,

The syntax is correct if structured properly and will result in each "set" showing all records  for "All" (the argument will be true and therefore not filter) or if another value selected, it will filter on that. 

I have found at times that Search and Filter do not "play nice" together in complex queries and tend to use the in Filter (it has the same effect) with the others. If you post your entire code, I can look at it and offer something.

For your other question, you can use a Collection with the same syntax, and then set any relevant gallery Items to the collection.

 

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.

 

 

Hello @WarrenBelz ,

 

Look the code below, it is not looking up values in my gallery. The message error is "The Search part of this formula does not work in large amount of data". (I have set 2000 rows to be recovered from data)

 

With(
{
wDD1:Filt_Resp.Selected.Result;
wDD2:Filt_Star.Selected.Result;
wDD3:Filt_Status.Selected.Result
};
SortByColumns(
Search(
Filter(
'MYLIST';
(wDD1 = "All" || Líder = wDD1) &&
(wDD2 = "All" || Estrela = wDD2) &&
(wDD3 = "All" || Status = wDD3)
);
TextInput2.Text;
"Oportunidade";
"Cliente"
);
"Estrela";
Descending;
"Cliente";
Ascending
)
)

 

RodrigoCastelli_0-1609242372338.png

 

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

 

The second question i really don't understand yet. I need my filter button be exacly the same after change screens.

Could you be more specific?

 

Best regards,

@RodrigoCastelli ,

That is a Delegation error - this blog of mine may be worth a read for you if you don't understand this.

Apart from that, if you have less than 2,000 items in your list (and always will have), you can get rid of the warning like this

With(
   {
      wDD1:Filt_Resp.Selected.Result;
      wDD2:Filt_Star.Selected.Result;
      wDD3:Filt_Status.Selected.Result;
      wList:MYLIST
   };
   SortByColumns(
      Search(
         Filter(
            wList;
            (wDD1 = "All" || Líder = wDD1) &&
            (wDD2 = "All" || Estrela = wDD2) &&
            (wDD3 = "All" || Status = wDD3)
         );
         TextInput2.Text;
         "Oportunidade";
         "Cliente"
      );
      "Estrela";
      Descending;
      "Cliente";
      Ascending
   )
)

Also what is it you do not understand abut doing a Collection with the same data?

 

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.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,303)