cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
arpit_vijay
New Member

Filtering gallery using dropdown


HI,

I am trying to filter my gallery according to Years and Month dropdown. Trying to set the dependency on selected year and set according to that the value of the month.
Gallery name = Gallery1

 

Filter('DataSource',Month = month_dropdown.Selected.Month, Year = year_drop_down.Selected.Year)
 
Month and Year are coming from two different collections i.e. 
ClearCollect(collyear,{Result:"All"});
Collect(collyear,Distinct('Datasource',Year));
ClearCollect(collmonth,{Result:"All"});
Collect(collmonth,Distinct('Datasource',Month))

Help me to find the solution as soon as possible!
1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @arpit_vijay ,

 

Do you mean you want to use dependencies to change the Month value depending on what chosen in Year dropdown, right?

If so, please modify the code as follows.

1. set the OnChange property of year dropdown:

ClearCollect(collmonth,{Result:"All"});
Collect(collmonth,Distinct(Filter('Datasource',Year=Self.Selected.Result),Month))

2. modify the Gallery1.Items property:

Filter(
'DataSource',
If(month_dropdown.Selected.Month="All",true,Month = month_dropdown.Selected.Result), 
If(year_drop_down.Selected.Year="All",true,Year = year_drop_down.Selected.Year)
)

Hope this helps.

Sik 

View solution in original post

2 REPLIES 2
VijayTailor
Resident Rockstar
Resident Rockstar

Hi @arpit_vijay ,

Before filter you need to check Month and Year column is what type in DataSource.

if the is Single like text then you can filter simple way as you mentioned.

But Month /Year Column is DateTyp then You can use code like below.

Filter('DataSource',Month = DateValue(Text(month_dropdown.Selected.Month,"mm"/"mmm") && Year = DateValue(Text(year_drop_down.Selected.Year,"yy"/"yyyy"))).

mm - 02
mmm - Jan
yy - 20
yyyy - 2020

.
Thanks,
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

v-siky-msft
Community Support
Community Support

Hi @arpit_vijay ,

 

Do you mean you want to use dependencies to change the Month value depending on what chosen in Year dropdown, right?

If so, please modify the code as follows.

1. set the OnChange property of year dropdown:

ClearCollect(collmonth,{Result:"All"});
Collect(collmonth,Distinct(Filter('Datasource',Year=Self.Selected.Result),Month))

2. modify the Gallery1.Items property:

Filter(
'DataSource',
If(month_dropdown.Selected.Month="All",true,Month = month_dropdown.Selected.Result), 
If(year_drop_down.Selected.Year="All",true,Year = year_drop_down.Selected.Year)
)

Hope this helps.

Sik 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,143)