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 / Filter gallery based o...
Power Apps
Answered

Filter gallery based on 2 checkboxes & searchbox

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello everyone!

Formula I have right now: 

If(
 Checkbox2_1.Value = false && Checkbox2.Value = true; 
 If(
 IsBlank(TekstZoekVeld_1.Text);
 Distinct(
 Lijst_Eindp;
 Omschrijving
 );
 Filter(
 Distinct(
 Lijst_Eindp;
 Omschrijving
 );
 TekstZoekVeld_1.Text in Result
 )
))

 

What we need to add is an if statement that checks the other way around, Checkbox2_1.value = true && Checkbox 2.value = false

Then it needs to get information out of the database Lijst_Eindp

Out of this database we are going to use 2 columns. One is named 'Prod. usage' and one is named Omschrijving. So whenever checkbox2_1 is true and checkbox 2 is false, it needs to show all Omschrijving rows where 'Prod. usage' is equal to "Bev. M; Montage"

I also have a searchtextbox. Whenever they type something in here, it needs to filter the amount of options inside of my dropdown (Omschrijving). 

Categories:
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Anyone able to help me with this?

  • GarethPrisk Profile Picture
    2,828 on at

    A few observations:

    You can simply keep extending your If statement to function as If, Else If, Else

    If(
     // If Branch
     Checkbox1.Value = false && Checkbox2.Value = true,
     If(
     IsBlank(TekstZoekVeld_1.Text),
     Distinct(
     Lijst_Eindp,
     Omschrijving
     ),
     Filter(
     Distinct(
     Lijst_Eindp,
     Omschrijving
     ),
     TekstZoekVeld_1.Text in Result
     )
     ),
     // Else If Branch
     Checkbox1.Value = true && Checkbox2.Value = false,
     If(
     IsBlank(TekstZoekVeld_1.Text),
     Distinct(
     Lijst_Eindp,
     Omschrijving
     ),
     Filter(
     Distinct(
     Lijst_Eindp,
     Omschrijving
     ),
     TekstZoekVeld_1.Text in Result
     )
     ),
     // Else
     Blank()
    )

    I copied the first branch and just inverted the logic. You'd need to update for your purposes to include your new columns.

     

    The DropDown usage I think is a bit backwards - at least how you've asked for it to be used relative to it being included in the function. "Whenever they type something in here, it needs to filter the amount of options inside of my dropdown (Omschrijving)" Where is this drop-down? In the function, it's used as a filter parameter explicitly. Are you trying to filter the gallery using this dropdown, or filter the drop-down based on the checkboxes being checked?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for your answer @GarethPrisk 

    Sorry for confusing you. I will explain it better now.

    We're filtering a dropdown box. The code you sent me will be inside of the "Items" section for the dropdown box. 

     

    This is what I want:

    1. When Checkbox1.Value = true && Checkbox2.Value = false

    I want it to filter the dropdown box on "Bev M; Montage". The column name is "Prod. usage", the database name is "Lijst_eindp". Now it may get a little bit complicated. So I want to filter it on the column "Prod. usage" on all values with "Bev M; Montage" but instead of getting the "Bev M; Montage, I want to lookup the column Omschrijving that has "Bev M; Montage" as "Prod. usage". 

    To explain this, I'll attach a picture down here. So basically what should happen if Checkbox1 = true, it should filter on "Bev M; Montage" and show the "Omschrijving". For this example it would show only 1 row, as there is only 1 bev montage.  

    TimoMigchielsen_0-1597646089480.png

     

     

    2. Right now you can only search using the same column as the information is in. For example: 

    if this would be the only result in the dropdown box (It would only show the Omschrijving). You can only search on "PaneelHek L= 2304 B= 864 D= 60"

    How can I make it so I can also search for "3000-V-E; glaspaneel" and it will show all of the "Omschrijving" that are available?

    TimoMigchielsen_1-1597646207235.png

    Thanks for your response in advance! 

     

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    I am a little confused. Is the search you mentioned in point 2 based on the filtered list in point 1?

    If so, please try this.

    If(
     Checkbox2_1.Value = false && Checkbox2.Value = true; 
     If(
     IsBlank(TekstZoekVeld_1.Text);
     Distinct(
     Lijst_Eindp;
     Omschrijving
     );
     Filter(
     Distinct(
     Lijst_Eindp;
     Omschrijving
     );
     TekstZoekVeld_1.Text in Result
     )
    );
     Checkbox2_1.Value = true && Checkbox2.Value = false; 
     RenameColumns(Search(Filter(Lijst_Eindp; 'Prod. usage'="Bev M; Montage");searchtextbox.Text;"Prod. usage").Omschrijving;"Omschrijving";"Result")
    )

    If not, the search is in the first priority, right?

    If(IsBlank(searchtextbox.Text);
    If(
     Checkbox2_1.Value = false && Checkbox2.Value = true; 
     If(
     IsBlank(TekstZoekVeld_1.Text);
     Distinct(
     Lijst_Eindp;
     Omschrijving
     );
     Filter(
     Distinct(
     Lijst_Eindp;
     Omschrijving
     );
     TekstZoekVeld_1.Text in Result
     )
    );
     Checkbox2_1.Value = true && Checkbox2.Value = false; 
     RenameColumns(Filter(Lijst_Eindp; 'Prod. usage'="Bev M; Montage").Omschrijving;"Omschrijving";"Result")
    );
    RenameColumns(Search(Lijst_Eindp;searchtextbox.Text;"Prod. usage").Omschrijving;"Omschrijving";"Result")
    )

    Hope this helps.

    Sik 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for your answer @v-siky-msft .

    I just tried your code but it gives me an error for the search function. 

     

    I'll make it a little bit more visible:

     

    If checkbox 2_1 = true && 2 = false

    1. It has to show the column "Omschrijving"
    2. It needs to filter the column "Prod. usage" on "Bev M; Montage" and it needs to show the "Omschrijving" for each row that has the prod usage "Bev M; Montage".
    3. The search then just searched for the Omschrijving

     

    If checkbox 2 = true && 2_1 = false
    1. It has to show the column "Omschrijving"
    2. Search option needs to search both columns if possible, Omschrijving & Prod. usage. 

    When they are both false, show nothing

    Thank you for your answer in advance!

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Got it. Please try this.

    If(
     Checkbox2_1.Value = false && Checkbox2.Value = true; 
     If(
     IsBlank(TekstZoekVeld_1.Text);
     Distinct(
     Lijst_Eindp;
     Omschrijving
     );
     Distinct(
     Filter(
     Lijst_Eindp;
     TekstZoekVeld_1.Text in 'Prod. usage'|| TekstZoekVeld_1.Text in Omschrijving
     );Omschrijving)
     );
     Checkbox2_1.Value = true && Checkbox2.Value = false; 
     If(
     IsBlank(TekstZoekVeld_1.Text);
     Distinct(Filter(Lijst_Eindp; 'Prod. usage'="Bev M; Montage"),Omschrijving);
     Distinct(Filter(Lijst_Eindp; 'Prod. usage'="Bev M; Montage",TekstZoekVeld_1.Text in Omschrijving),Omschrijving)
     )
    )

     Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I think this works.

    It says the maximum amount has been reached though. Is there anything I can do about this? @v-siky-msft 

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

     

    It seems you have reached the maximum numbers of items that can be list in dropdown box.

     

    Could you please consider changing to use Gallery to work as a dropdown?

    Add a Textinput to display the selected items, put the code above to Gallery.Items property that can show entire table, Set the Gallery visible property to hide it in until the textinput is clicked. At last, use Gallery.Selected code to output the selection.

     

    Hope this helps.

    Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-siky-msft 

    I do not want to use a gallery, is there no other option? @v-siky-msft 

    Are we not able to create a collection of my database and then use the collection name instead of my database?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-siky-msft There is an issue with this code. 

    https://gyazo.com/60b9e2b40168487e00d01a458cd5398a

    In the following gif I was searching for "Zwarte"

    But I couldn't find it. Do you maybe know why this is happening?


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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard