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 / Create multiple filter...
Power Apps
Answered

Create multiple filters on a gallery

(0) ShareShare
ReportReport
Posted on by 519

Hello,

 

I have a gallery control that has the following formula on the Items property and is linked to one dropdown and a search field:

 

If(vUserRole = "SPA" || vUserRole = "VIEW",
SortByColumns(
Search(
Filter(Corp_Com_List, 'SPA ID' = varSPAID), TextInput2.Text, "Provision","Frequency","SubmissionStatus", "Title", "ValidationStatus"),
Dropdown2.SelectedText.Value,
If(
ctxSortDescending,
SortOrder.Ascending,
SortOrder.Descending
)
)
,
SortByColumns(
Search(Corp_Com_List, TextInput2.Text, "Provision","Frequency","SubmissionStatus", "Title", "ValidationStatus", "ValidationStatus"),
Dropdown2.SelectedText.Value,
If(
ctxSortDescending,
SortOrder.Ascending,
SortOrder.Descending
)


))

 

In addition to the above, I wanted to create separate dropdown fields that stores the relevant statuses of each record, so that users can select a status from the dropdown and only the items in the gallery with that status will be displayed.  I have two dropdown fields I want to filter by:  one for Validation Status and another for Submission Status.  I also wanted to include an option to filter by date range, to see all of the items that were created within a particular period From and to dates , etc.  I am not sure what code to use or how to add same to the existing formula above without triggering any errors.  Any guidance appreciated.

Categories:
  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @joshieboy ,

     

    Please try below formula, I assume you have two Dropdowns, a From Date Picker and a To Date Picker:

    If(
     vUserRole = "SPA" || vUserRole = "VIEW",
     SortByColumns(
     Search(
     Filter(
     Corp_Com_List, 
     'SPA ID' = varSPAID && 'Validation Status' = ValStatusDropdown.Selected.Value && 'Submission Status' = SubStatusDropdown.Selected.Value,
     Created >= FromDatePicker.SelectedDate && Created <= ToDatePicker.SelectedDate
     ), 
     TextInput2.Text, 
     "Provision","Frequency","SubmissionStatus", "Title", "ValidationStatus"
     ),
     Switch(
     Dropdown2.Selected.Value,
     Column1, "Column1",Column2, "Column2",Column3, "Column3",...
     ),
     If(
     ctxSortDescending,
     SortOrder.Ascending,
     SortOrder.Descending
     )
     ),
     SortByColumns(
     Search(
     Filter(
     Corp_Com_List, 
     'Validation Status' = ValStatusDropdown.Selected.Value && 'Submission Status' = SubStatusDropdown.Selected.Value,
     Created >= FromDatePicker.SelectedDate && Created <= ToDatePicker.SelectedDate
     ),
     TextInput2.Text, 
     "Provision","Frequency","SubmissionStatus", "Title", "ValidationStatus", "ValidationStatus"
     ),
     Switch(
     Dropdown2.Selected.Value,
     Column1, "Column1",Column2, "Column2",Column3, "Column3",...
     ),
     If(
     ctxSortDescending,
     SortOrder.Ascending,
     SortOrder.Descending
     )
     )
    )

     

    The Dropdown2 seems to be a column name that needs to be sort on, however, it only support to use static column names for the SortByColumns function. So you can see I've made a change to use Switch function to check the selected column name.

     

    Best regards,

  • joshieboy Profile Picture
    519 on at

    Hello @v-jefferni - thank you for the prompt feedback on this.  That is correct with the dropdown2.  Trying to implement your code now.  

    Should I replace this 

    Column1, "Column1",Column2, "Column2",Column3, "Column3",...

    with the actual values in dropdown2?  What should go here?

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @joshieboy ,

     

    The names without quotes are from Dropdown2 selected values, those with quotes are actual names in Corp_Com_List list.

     

    Best regards,

  • joshieboy Profile Picture
    519 on at

    Hello @v-jefferni - this seems to be working.  Thanks.  In my dropdown2 though, the items property is set to this:

    [
    Blank(),
    "Created",
    "Provision",
    "Frequency",
    "SubmissionDueDate" ,
    "SubmissionStatus",
    "ReportingStartDate",
    "ValidationStatus",
    "Title",
    ]

    Once the field is blank, all records in the gallery show which is great.  When I introduce a new dropdown for the Submission Status, and use the below in its items property, because submission status has the following options, although I used blank similarly to the dropdown2, submission defaults to Assigned, and only shows assigned items in the gallery.  While this works well based on the formula you gave me, I would like this field to be default blank and show all items first before a user commences selecting an option.  Not sure what is going on there.:  

    [
    Blank(),
    "Assigned",
    "Submitted for Validation (Record Locked)",
    "Work In Progress",
    ]

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @joshieboy ,

     

    So, Dropdown2 is used for selecting a column to sort by, but the SubStatusDropdown is used for filtering the Submission Status column, am I right?

     

    If this is the case, you can modify the criteria in the Filter functions as in below formula:

     

    If(
     vUserRole = "SPA" || vUserRole = "VIEW",
     SortByColumns(
     Search(
     Filter(
     Corp_Com_List, 
     'SPA ID' = varSPAID && 'Validation Status' = ValStatusDropdown.Selected.Value && If(IsBlank(SubStatusDropdown.Selected), true, 'Submission Status' = SubStatusDropdown.Selected.Value),
     Created >= FromDatePicker.SelectedDate && Created <= ToDatePicker.SelectedDate
     ), 
     TextInput2.Text, 
     "Provision","Frequency","SubmissionStatus", "Title", "ValidationStatus"
     ),
     Switch(
     Dropdown2.Selected.Value,
     Column1, "Column1",Column2, "Column2",Column3, "Column3",...
     ),
     If(
     ctxSortDescending,
     SortOrder.Ascending,
     SortOrder.Descending
     )
     ),
     SortByColumns(
     Search(
     Filter(
     Corp_Com_List, 
     'Validation Status' = ValStatusDropdown.Selected.Value && If(IsBlank(SubStatusDropdown.Selected), true, 'Submission Status' = SubStatusDropdown.Selected.Value),
     Created >= FromDatePicker.SelectedDate && Created <= ToDatePicker.SelectedDate
     ),
     TextInput2.Text, 
     "Provision","Frequency","SubmissionStatus", "Title", "ValidationStatus", "ValidationStatus"
     ),
     Switch(
     Dropdown2.Selected.Value,
     Column1, "Column1",Column2, "Column2",Column3, "Column3",...
     ),
     If(
     ctxSortDescending,
     SortOrder.Ascending,
     SortOrder.Descending
     )
     )
    )

     

     

    Best regards,

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 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard