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

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

How to combine both syntax (if/filter/search) in Item-Property of Gallery?

(0) ShareShare
ReportReport
Posted on by 11

Hi everyone,

I'm trying to combine an if-syntax with the filter and search syntax in the item-property of the gallery. Individual text passages work. Does anyone have an idea how I can combine the two syntax together?"

 

If (ComboboxCanvas1.Selected.Value = "Erstellt am"; Sort('A3 Report Backend';Erstellt;varSortDirection);
 ComboboxCanvas1.Selected.Value = "Kategorie"; Sort('A3 Report Backend'; Kategorie.Value; varSortDirection);
 ComboboxCanvas1.Selected.Value = "Thema"; Sort('A3 Report Backend'; Hauptthema_v2; varSortDirection);
 ComboboxCanvas1.Selected.Value = "Team"; Sort('A3 Report Backend'; Team.Value; varSortDirection);
 ComboboxCanvas1.Selected.Value = "Verantwortlich"; Sort('A3 Report Backend'; Verantwortlich.DisplayName; varSortDirection));;

Filter(
 Search('A3 Report Backend'; '0_tb_FilterSearch_Search'.Value; Hauptthema_v2);
 (IsBlank('0_cb_FilterSearch_Kategorie'.Selected) || Kategorie.Value = '0_cb_FilterSearch_Kategorie'.Selected.Value) &&
 (IsBlank('0_cb_FilterSearch_Team'.Selected) || Team.Value = '0_cb_FilterSearch_Team'.Selected.Value) &&
 (IsBlank('0_cb_FilterSearch_Region'.Selected) || Region.Value = '0_cb_FilterSearch_Region'.Selected.Value) &&
 (IsBlank('0_cb_FilterSearch_Projektart'.Selected) || Projektart.Value = '0_cb_FilterSearch_Projektart'.Selected.Value) &&
 (IsBlank('0_cb_FilterSearch_Projektgroesse'.Selected) || Projektgroesse.Value = '0_cb_FilterSearch_Projektgroesse'.Selected.Value) &&
 (IsBlank('0_cb_FilterSearch_Bedarfstraeger'.Selected) || Bedarfsträger.DisplayName = '0_cb_FilterSearch_Bedarfstraeger'.Selected.DisplayName) &&
 (IsBlank('0_cb_FilterSearch_Verantwortlich'.Selected) || Verantwortlich.DisplayName = '0_cb_FilterSearch_Verantwortlich'.Selected.DisplayName) &&
 (IsBlank('0_tb_FilterSearch_SAPNr'.Value) || SAP_Nummer = '0_tb_FilterSearch_SAPNr'.Value) &&
 Erstellt >= '0_dp_FilterSearch_FromDate'.Value && Erstellt <= '0_dp_FilterSearch_ToDate'.Value)

 


I would appreciate any response.
Thx Adam

I have the same question (0)
  • WarrenBelz Profile Picture
    151,895 Most Valuable Professional on at
    Re: How to combine both syntax (if/filter/search) in Item-Property of Gallery?

    Hi @Adam9595 ,

    You will have Delegation issues with the sorting on the Complex field types, but your Search is not Delegable anyway, so to combine them

    With(
     {
     _Data:
     Filter(
     'A3 Report Backend';
     (
     Len('0_cb_FilterSearch_Kategorie'.Selected.Value) = 0 || 
     Kategorie.Value = '0_cb_FilterSearch_Kategorie'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Team'.Selected.Value) = 0 || 
     Team.Value = '0_cb_FilterSearch_Team'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Region'.Selected.Value) = 0 || 
     Region.Value = '0_cb_FilterSearch_Region'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Projektart'.Selected.Value = 0 || 
     Projektart.Value = '0_cb_FilterSearch_Projektart'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Projektgroesse'.Selected.Value = 0 || 
     Projektgroesse.Value = '0_cb_FilterSearch_Projektgroesse'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Bedarfstraeger'.Selected.DisplayName = 0 || 
     Bedarfsträger.DisplayName = '0_cb_FilterSearch_Bedarfstraeger'.Selected.DisplayName
     ) &&
     (
     Len('0_cb_FilterSearch_Verantwortlich'.Selected.DisplayName = 0 || 
     Verantwortlich.DisplayName = '0_cb_FilterSearch_Verantwortlich'.Selected.DisplayName
     ) &&
     (
     Len('0_tb_FilterSearch_SAPNr'.Value) = 0 || 
     SAP_Nummer = '0_tb_FilterSearch_SAPNr'.Value
     ) &&
     Erstellt >= '0_dp_FilterSearch_FromDate'.Value && 
     Erstellt <= '0_dp_FilterSearch_ToDate'.Value
     )
     };
     Sort(
     Search(
     _Data;
     '0_tb_FilterSearch_Search'.Value; 
     Hauptthema_v2
     );
     Switch(
     ComboboxCanvas1.Selected.Value;
     "Erstellt am";
     Erstellt;
     "Kategorie"; 
     Kategorie.Value;
     "Thema"; 
     Hauptthema_v2; 
     "Team";
     Team.Value; 
     "Verantwortlich"; 
     Verantwortlich.DisplayName
     ); 
     varSortDirection
    );;

    If you want some Delegation management (the top With() output (List can be of any size) needs to be under your Data Row limit }

    With(
     {
     _Data:
     Filter(
     'A3 Report Backend';
     (
     Len('0_cb_FilterSearch_Kategorie'.Selected.Value) = 0 || 
     Kategorie.Value = '0_cb_FilterSearch_Kategorie'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Team'.Selected.Value) = 0 || 
     Team.Value = '0_cb_FilterSearch_Team'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Region'.Selected.Value) = 0 || 
     Region.Value = '0_cb_FilterSearch_Region'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Projektart'.Selected.Value = 0 || 
     Projektart.Value = '0_cb_FilterSearch_Projektart'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Projektgroesse'.Selected.Value = 0 || 
     Projektgroesse.Value = '0_cb_FilterSearch_Projektgroesse'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Bedarfstraeger'.Selected.DisplayName = 0 || 
     Bedarfsträger.DisplayName = '0_cb_FilterSearch_Bedarfstraeger'.Selected.DisplayName
     ) &&
     (
     Len('0_cb_FilterSearch_Verantwortlich'.Selected.DisplayName = 0 || 
     Verantwortlich.DisplayName = '0_cb_FilterSearch_Verantwortlich'.Selected.DisplayName
     ) &&
     (
     Len('0_tb_FilterSearch_SAPNr'.Value) = 0 || 
     SAP_Nummer = '0_tb_FilterSearch_SAPNr'.Value
     ) &&
     Erstellt >= '0_dp_FilterSearch_FromDate'.Value && 
     Erstellt <= '0_dp_FilterSearch_ToDate'.Value
     )
     };
     Sort(
     Search(
     _Data;
     '0_tb_FilterSearch_Search'.Value; 
     Hauptthema_v2
     );
     Switch(
     ComboboxCanvas1.Selected.Value;
     "Erstellt am";
     Erstellt;
     "Kategorie"; 
     Kategorie.Value;
     "Thema"; 
     Hauptthema_v2; 
     "Team";
     Team.Value; 
     "Verantwortlich"; 
     Verantwortlich.DisplayName
     ); 
     varSortDirection
    );;

     

    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

  • Adam9595 Profile Picture
    11 on at
    Re: How to combine both syntax (if/filter/search) in Item-Property of Gallery?

    Hi @WarrenBelz 
    thank you for your message. I use SharePoint List, where overall not more than >5000 records.

    So i think, delegation will be not a problem. 

    I tryed your syntax, but didn`t works. Does the syntax copy to Item-Property of the Gallery?
    Could you explain, in which context is "_Data" in your Syntax?

    Thanks
    Adam


  • WarrenBelz Profile Picture
    151,895 Most Valuable Professional on at
    Re: How to combine both syntax (if/filter/search) in Item-Property of Gallery?

    Hi @Adam9595 ,

    Firstly Delegation is an issue if your List numbers are over your Data Row Limit which is 500 by Default and can be increased to maximum of 2,000. The With() statement is “pre-filtering” your Data with (in the second code) the Delegable parts of the filter and storing it in a (very) temporary Table which is then actioned “locally” by Power Apps. You can call this whatever you want - I used _Data.

    What is not working (are you getting an error, if so what) ? To you last question, yes it is the Items of the Gallery.

  • Adam9595 Profile Picture
    11 on at
    Re: How to combine both syntax (if/filter/search) in Item-Property of Gallery?

    Hello WarrenBelz,

    Thank you for your message and sorry for my late reply. PowerApps accesses 3 entries that are in my SharePoint list. For example, when I enter the name of my database as Items 'A3 Report Backend', my 3 entries are loaded. However, when I enter your syntax, nothing is displayed. I get the following errors:

     

     

    1. Error
    Unexpected character. The formula receives "CurlyClose" but "ParenClose" is expected.
    
    This error occurs when a formula contains something like "{Val@ 7}" instead of "{Val: 7}". When you set a variable, the syntax requires a colon instead of an @ symbol.
    
    Location: Gallery 2.Items.
    
    How to fix:
    
    Remove the unexpected character or replace it with the expected character.

     

     

     

    2. Error
    Operator expected. An operator like +, *, or & is expected at this point in the formula. Operators connect two operands. This error occurs when you connect two functions (operands) without placing an operator between them. Example: Len("MyText")Len("MyText").
    
    Location: Gallery2.Items.
    
    How to fix:
    
    Edit your formula so that it contains an operator between the operands.

     

    Could you help? 

    Thanks
    Adam

  • WarrenBelz Profile Picture
    151,895 Most Valuable Professional on at
    Re: How to combine both syntax (if/filter/search) in Item-Property of Gallery?

    Hi @Adam9595 ,

    That really does not help me identify the issue. I have double-checked the code I posted and it is correct structure providing your values are valid. Can you please post the exact code you are using in the Items of the Gallery in Text and can you also list out the field types of all the fields referenced. Also if you cut off the bottom part and do this, do you get any errors? This is only trying to identify which part of the code is the issue.

    With(
     {
     _Data:
     Filter(
     'A3 Report Backend';
     (
     Len('0_cb_FilterSearch_Kategorie'.Selected.Value) = 0 || 
     Kategorie.Value = '0_cb_FilterSearch_Kategorie'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Team'.Selected.Value) = 0 || 
     Team.Value = '0_cb_FilterSearch_Team'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Region'.Selected.Value) = 0 || 
     Region.Value = '0_cb_FilterSearch_Region'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Projektart'.Selected.Value = 0 || 
     Projektart.Value = '0_cb_FilterSearch_Projektart'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Projektgroesse'.Selected.Value = 0 || 
     Projektgroesse.Value = '0_cb_FilterSearch_Projektgroesse'.Selected.Value
     ) &&
     (
     Len('0_cb_FilterSearch_Bedarfstraeger'.Selected.DisplayName = 0 || 
     Bedarfsträger.DisplayName = '0_cb_FilterSearch_Bedarfstraeger'.Selected.DisplayName
     ) &&
     (
     Len('0_cb_FilterSearch_Verantwortlich'.Selected.DisplayName = 0 || 
     Verantwortlich.DisplayName = '0_cb_FilterSearch_Verantwortlich'.Selected.DisplayName
     ) &&
     (
     Len('0_tb_FilterSearch_SAPNr'.Value) = 0 || 
     SAP_Nummer = '0_tb_FilterSearch_SAPNr'.Value
     ) &&
     Erstellt >= '0_dp_FilterSearch_FromDate'.Value && 
     Erstellt <= '0_dp_FilterSearch_ToDate'.Value
     )
     };
     _Data
    )

    and then as a second exercise do this

    With(
     {_Data: 'A3 Report Backend'}; 
     Sort(
     Search(
     _Data;
     '0_tb_FilterSearch_Search'.Value; 
     Hauptthema_v2
     );
     Switch(
     ComboboxCanvas1.Selected.Value;
     "Erstellt am";
     Erstellt;
     "Kategorie"; 
     Kategorie.Value;
     "Thema"; 
     Hauptthema_v2; 
     "Team";
     Team.Value; 
     Verantwortlich.DisplayName
     ); 
     varSortDirection
     )
    );;

     

  • Adam9595 Profile Picture
    11 on at
    Re: How to combine both syntax (if/filter/search) in Item-Property of Gallery?

    Hi @WarrenBelz ,
    thank you very much for your message. I tried the split syntax, but neither was recognized by PowerApps.

    I have created some screenshots attached, which show the controls used and their names & types. "0_cb_FilterSearch_Bedarfsträger" and "0_cb_FilterSearch_Verantwortlich" are person fields.

    Additionally, here is an excerpt from the database.

     

    Thank you,

    Adam

  • WarrenBelz Profile Picture
    151,895 Most Valuable Professional on at
    Re: How to combine both syntax (if/filter/search) in Item-Property of Gallery?

    @Adam9595 ,

    One issue in the bottom code could be (see AddColumns)

    With(
     {_Data: 'A3 Report Backend'}; 
     Sort(
     Search(
     AddColumns(
     _Data;
     SearchValue;
     '0_tb_FilterSearch_Search'.Value;
     );
     SearchValue, 
     Hauptthema_v2
     );
     Switch(
     ComboboxCanvas1.Selected.Value;
     "Erstellt am";
     Erstellt;
     "Kategorie"; 
     Kategorie.Value;
     "Thema"; 
     Hauptthema_v2; 
     "Team";
     Team.Value; 
     Verantwortlich.DisplayName
     ); 
     varSortDirection
     )
    );;

    but you are going to have to do some work here and start off with one value and then keep adding until it breaks as I cannot see your data or app. Also I need (as asked before - a non-English screenshot does not help me) in Text, the exact code you are using and (also in Text) the field and control names and types (for both).
    Also can you please try Classic Controls instead of the Modern items as the issue may lie there.

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 624 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 381 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 225

Last 30 days Overall leaderboard