web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Can't merge 2 differen...
Power Apps
Answered

Can't merge 2 different code into one to filter a gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi guys!

I'm reaching out to get some help with merging 2 different parts of code I have written. They work independently but I can't figure out a way to take the first code and merge it with the second.

Any help is very much appreciated!

 

1. First code, filtering the gallery with a combobox that displays Office 365 users

If(
 IsEmpty(ComboBox2_5.SelectedItems);
 lst_suivi_materiel;
 Filter(
 lst_suivi_materiel;
 'Agent Propriétaire'.DisplayName in ComboBox2_5.SelectedItems.DisplayName)
)

 

2. Second code, that shows all the other filters for the gallery

Sort(//On trie par date dans l'ordre ascendant les résultats
 Search(//on permet de rechercher grâce à "Search_IMEI.Text" le texte entré dans la liste
 Filter(//ici on filtre la liste en affichant toujours au minimum tous les éléments, puis on trie par UO, type de matériel et agent
 lst_suivi_materiel;
 (IsBlank(Combo_UO_4.Selected.Value) || StartsWith(
 UO;
 Combo_UO_4.Selected.Value
 )) && (IsBlank(Cat_Combo_2.Selected.Value) || StartsWith(
 Type_de_materiel;
 Cat_Combo_2.Selected.Value
 )) && (IsBlank(Cat_Combo_3.Selected.Value) || StartsWith(
 Disponibilité;
 Cat_Combo_3.Selected.Value
 ))
 );
 Search_IMEI_1.Text;
 "Title" 
 );
 'Date de dotation';
 SortOrder.Ascending
)

 

Thanks!

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    Hi @Anonymous ,

    Try this - I am also wondering why you are using StartsWith on the Combo Boxes when it would usually be an exact match.

    Sort(
     Search(
     Filter(
     lst_suivi_materiel;
     (
     IsBlank(Combo_UO_4.Selected.Value) || 
     StartsWith(
     UO;
     Combo_UO_4.Selected.Value
     )
     ) && 
     (
     IsBlank(Cat_Combo_2.Selected.Value) || 
     StartsWith(
     Type_de_materiel;
     Cat_Combo_2.Selected.Value
     )
     ) && 
     (
     IsBlank(Cat_Combo_3.Selected.Value) || 
     StartsWith(
     Disponibilité;
     Cat_Combo_3.Selected.Value
     )
     ) &&
     (
     IsEmpty(ComboBox2_5.SelectedItems) ||
     Agent Propriétaire'.DisplayName in ComboBox2_5.SelectedItems.DisplayName
     )
     );
     Search_IMEI_1.Text;
     "Title" 
     );
     'Date de dotation';
     SortOrder.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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for your answer!
    I was using StartsWith because I am only using a ComboBox for the user research every other "Cat_Combo" is actually a dropdown.

     

    Pasting your formula into the Items parameter of the Gallery I have "&&" ; "||" and "in" underlined in blue saying they don't work well on large databases. And also, when nothing is selected it still displays an empty gallery.

    so_fortyfour_0-1681887208862.png

     

  • WarrenBelz Profile Picture
    154,930 Most Valuable Professional on at

    @Anonymous ,

    That is correct - the in filter is not Delegable, however the code I provided was simply copying the two elements of what you posted - if they worked for you, then the combined code should. If you want to improve the Delegation quality, you can do this

    With(
     {
     wData:
     Sort(
     Filter(
     lst_suivi_materiel;
     (
     Len(Combo_UO_4.Selected.Value) = 0 || 
     StartsWith(
     UO;
     Combo_UO_4.Selected.Value
     )
     ) && 
     (
     Len(Cat_Combo_2.Selected.Value) = 0 || 
     StartsWith(
     Type_de_materiel;
     Cat_Combo_2.Selected.Value
     )
     ) && 
     (
     Len(IsBlank(Cat_Combo_3.Selected.Value) = 0 || 
     StartsWith(
     Disponibilité;
     Cat_Combo_3.Selected.Value
     )
     )
     );
     'Date de dotation'
     )
     };
     Search(
     Filter(
     wData;
     IsEmpty(ComboBox2_5.SelectedItems) ||
     Agent Propriétaire'.DisplayName in ComboBox2_5.SelectedItems.DisplayName
     );
     Search_IMEI_1.Text;
     "Title" 
     )
    )

    but you need to be aware that the record numbers out of the top With() statement need to be under your Delegation limit. 

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi again! Thanks for you answer, this solution wasn't working but I have figured out a way to make it work this is my final code for anyone encountering the same issue :

    Sort(
     Search(
     Filter(
     Datasource;
     (IsBlank(ComboBox.Selected.Value) || StartsWith(
     Column;
     ComboBox.Selected.Value
     )) && (IsBlank(ComboBox2.Selected.Value) || StartsWith(
     Column;
     ComboBox2.Selected.Value
     )) && (IsBlank(ComboBox3.Selected.Value) || StartsWith(
     Column;
     ComboBox3.Selected.Value
     )) && (IsBlank(ComboBox4.SelectedItems.DisplayName) || 
     ColumnUser.DisplayName in ComboBox4.SelectedItems.DisplayName
     )
     );
     SearchInput.Text;
     "Title" 
     );
     Column;
     SortOrder.Ascending
    )

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard