cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TobiasSQA
Frequent Visitor

Search bar with dropdown. Gallery uses If statement.

Hello there!

 

I'm making an app which has a gallery that shows a numbers of items that are delegated into categories. However I have run into an issue. 

 

I had the search field working when I didn't need to have a blank item choice in the dropdown menu, however now that I do, the "If" Statement is occupied so to speak. 

 

I would like it to work like this: If anything is in the search field, it should filter the items in the gallery based on that, if not, filter it based on the dropdown.

Below is a PNG Attached explaining the different elements

 

Thanks in Advance! 

 

Regards

Tobias SQ Andersen 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yujincui-msft
Community Support
Community Support

Hi @TobiasSQA ,

 

Based on your description:  If anything is in the search field, it should filter the items in the gallery based on that, if not, filter it based on the dropdown.

I have made a test for your reference.

 

1. Here is my SharePoint List.

vyujincuimsft_0-1651195236197.png

2. Select the Gallery Control and try to apply the formula like this:

If(
    !IsBlank(TextInput1.Text),
    Filter(
        datasource,
        TextInput1.Text in columnname
    ),
    If(
        !IsBlank(Dropdown1.Selected.Value),
        Filter(
            datasource,
            Dropdown1.Selected.Value = choicecoulumnname.Value
        ),
        datasource
    )
)

Result Screenshots:

vyujincuimsft_3-1651196330451.png

 

vyujincuimsft_2-1651196309085.png

In addition, if you want the search bar and dropdown to work together, maybe you could try the following formula:

Search(
    If(
        !IsBlank(Dropdown1.Selected.Value),
        Filter(
            datasource,
            Dropdown1.Selected.Value = choicecolumnname.Value
        ),
        datasource
    ),
    TextInput1.Text,
    "columnname"
)

Result Screenshot:

vyujincuimsft_4-1651197088069.png

 

 

Best Regards,

Charlie Choi

 

 

View solution in original post

3 REPLIES 3
v-yujincui-msft
Community Support
Community Support

Hi @TobiasSQA ,

 

Sorry, could you please provide your formula separately? The formula in your screenshot is not very clear.

 

Best Regards,

Charlie Choi

v-yujincui-msft
Community Support
Community Support

Hi @TobiasSQA ,

 

Based on your description:  If anything is in the search field, it should filter the items in the gallery based on that, if not, filter it based on the dropdown.

I have made a test for your reference.

 

1. Here is my SharePoint List.

vyujincuimsft_0-1651195236197.png

2. Select the Gallery Control and try to apply the formula like this:

If(
    !IsBlank(TextInput1.Text),
    Filter(
        datasource,
        TextInput1.Text in columnname
    ),
    If(
        !IsBlank(Dropdown1.Selected.Value),
        Filter(
            datasource,
            Dropdown1.Selected.Value = choicecoulumnname.Value
        ),
        datasource
    )
)

Result Screenshots:

vyujincuimsft_3-1651196330451.png

 

vyujincuimsft_2-1651196309085.png

In addition, if you want the search bar and dropdown to work together, maybe you could try the following formula:

Search(
    If(
        !IsBlank(Dropdown1.Selected.Value),
        Filter(
            datasource,
            Dropdown1.Selected.Value = choicecolumnname.Value
        ),
        datasource
    ),
    TextInput1.Text,
    "columnname"
)

Result Screenshot:

vyujincuimsft_4-1651197088069.png

 

 

Best Regards,

Charlie Choi

 

 

Hey Charlie

 

Once again this worked perfectly, thank you so much for the stellar assistance! You're almost doing too much 🙏

 

Kind Regards,

TobiasSQA

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (1,725)