cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marczh
Advocate I
Advocate I

Search Filter and Sort Gallery

Hi

I tried searching, filtering and sorting my gallery and almost suceeded 😉

 

I get the text box, the sort functions and one drop down filter to work, but when i try to include the second drop down filter, I fail.

 

marczh_0-1631798367332.png

With this code, the first drop down is working just fine.

SortByColumns(
    Search(
        If(
            DropdownStatus.Selected.Result = "Alle";
            'Reporting Vermietung';
            Filter(
                'Reporting Vermietung';
                'Status Text' = DropdownStatus.Selected.Result
            )
        );
        TextSearchBox1_1.Text;
        "Objekt";
        "PFM";
        "Status_x0020_Text";
        "Mieter"
    );
    SortColumn;
    If(
        SortDescending1;
        Descending;
        Ascending
    )
)

I tried to include the second filter drop down like this, but it's not working properly:

SortByColumns(
    Search(
        If(
            DropdownStatus.Selected.Result = "Alle" || DropdownPFM.Selected.Result = "Alle";
            'Reporting Vermietung';
            Filter(
                'Reporting Vermietung';
                'Status Text' = DropdownStatus.Selected.Result || PFM = DropdownPFM.Selected.Result
            )
        );
        TextSearchBox1_1.Text;
        "Objekt";
        "PFM";
        "Status_x0020_Text";
        "Mieter"
    );
    SortColumn;
    If(
        SortDescending1;
        Descending;
        Ascending
    )
)

Many thanks in advance 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @marczh

 

Both Dropdown selection is optional now.

With(
    {_Item: 'Reporting Vermietung'};
SortByColumns(
    Search(
Filter(
                _Item,
                (DropdownStatus.Selected.Result = "Alle" || 'Status Text' = DropdownStatus.Selected.Result) && (DropdownPFM.Selected.Result = "Alle" || PFM = DropdownPFM.Selected.Result)
            );
        TextSearchBox1_1.Text;
        "Objekt"
        "PFM";
        "Status_x0020_Text";
        "Mieter"
    );
    SortColumn;
    If(
        SortDescending1;
        Descending;
        Ascending
    )
)
)

 

 

 

View solution in original post

5 REPLIES 5
StalinPonnusamy
Super User
Super User

Hi @marczh

 

Please try this

With(
    {_Item: 'Reporting Vermietung'};
SortByColumns(
    Search(
        If(
            DropdownStatus.Selected.Result = "Alle" || DropdownPFM.Selected.Result = "Alle";
            _Item;
            Filter(
                _Item;
                'Status Text' = DropdownStatus.Selected.Result || PFM = DropdownPFM.Selected.Result
            )
        );
        TextSearchBox1_1.Text;
        "Objekt";
        "PFM";
        "Status_x0020_Text";
        "Mieter"
    );
    SortColumn;
    If(
        SortDescending1;
        Descending;
        Ascending
    )
)
)

When I select the first dropdown nothing happens when I select the second drop down it is filtering something in a wrong weird way. The search box is working finde. Eventough there is no error message from the code. 

 

I think the problem is maybe in the Or Statement for the two filters?

 

 

marczh
Advocate I
Advocate I

with this code 

 

With(
    {_Item: 'Reporting Vermietung'};
SortByColumns(
    Search(
        If(
            DropdownStatus.Selected.Result <> "Alle" Or DropdownPFM.Selected.Result <> "Alle";
            Filter(
                _Item;
                'Status Text' = DropdownStatus.Selected.Result Or PFM = DropdownPFM.Selected.Result
            );
            _Item
        );
        TextSearchBox1_1.Text;
        "Objekt";
        "PFM";
        "Status_x0020_Text";
        "Mieter"
    );
    SortColumn;
    If(
        SortDescending1;
        Descending;
        Ascending
    )
)
)

 

The Dropdowns are working but just if One of them is set to "Alle"

 

Is there a way they work both dynamically together despite the value of the other?

StalinPonnusamy
Super User
Super User

Hi @marczh

 

Both Dropdown selection is optional now.

With(
    {_Item: 'Reporting Vermietung'};
SortByColumns(
    Search(
Filter(
                _Item,
                (DropdownStatus.Selected.Result = "Alle" || 'Status Text' = DropdownStatus.Selected.Result) && (DropdownPFM.Selected.Result = "Alle" || PFM = DropdownPFM.Selected.Result)
            );
        TextSearchBox1_1.Text;
        "Objekt"
        "PFM";
        "Status_x0020_Text";
        "Mieter"
    );
    SortColumn;
    If(
        SortDescending1;
        Descending;
        Ascending
    )
)
)

 

 

 

marczh
Advocate I
Advocate I

@StalinPonnusamy Thank you very much, this works out just fine! Even if don't understand a 100% of the syntax 🙂

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,963)