cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MH3
Post Prodigy
Post Prodigy

Filter Gallery by Default All items and by Two Date Pickers

Hello Everyone,

I have a Gallery, I want to show all the data, when the user comes on this screen, and then when user selects date Range from top, the data should be displayed accordingly, somehow it's not working for me, the data does not show in the gallery when the user comes on the screen, however when the user selects the date range the data shows up.

 


What I have done is this

Gallery Items:

Sort(Filter('[dbo].[TimeSheet]',UserId= MyUser ,(Date>=DatePicker1_1.SelectedDate)&&(Date<=DatePicker1.SelectedDate)),Date,Ascending)


no_data.pngYes_data.png

is there a way to show all the Data by Default and then apply filter on that

Any Help

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @MH3 :

Do you want to implement the following functions

Case1:The user did not select the date in the two datapicker controls.

The gallery is displayed according to the following rules:

 

Sort(Filter('[dbo].[TimeSheet]',UserId= MyUser),Date,Ascending)

 

Case2:The user has selected a date in both date picker controls.

 

Sort(Filter('[dbo].[TimeSheet]',UserId= MyUser ,(Date>=DatePicker1_1.SelectedDate)&&(Date<=DatePicker1.SelectedDate)),Date,Ascending)

 

If so,I suggest you try this solution:

1\OnStart:

 

Set(var1,true);Set(var2,true);/*var1 and var2 is my custom variable*/

 

2\set the DatePicker1_1's OnChange property to:

 

Set(var1,false)

 

3\set the DatePicker1's OnChange property to:

 

Set(var2,false)

 

4\set the gallery's items property to:

 

Sort(If(var1 && var2,Filter('[dbo].[TimeSheet]',UserId= MyUser),Filter('[dbo].[TimeSheet]',UserId= MyUser ,(Date>=DatePicker1_1.SelectedDate)&&(Date<=DatePicker1.SelectedDate))),Created,Ascending)

 

Only when the options in both date selectors change, the records in the gallery are filtered according to the date selected by the user.

 Best Regards,

Bof

View solution in original post

4 REPLIES 4
v-bofeng-msft
Community Support
Community Support

Hi @MH3 :

Do you want to implement the following functions

Case1:The user did not select the date in the two datapicker controls.

The gallery is displayed according to the following rules:

 

Sort(Filter('[dbo].[TimeSheet]',UserId= MyUser),Date,Ascending)

 

Case2:The user has selected a date in both date picker controls.

 

Sort(Filter('[dbo].[TimeSheet]',UserId= MyUser ,(Date>=DatePicker1_1.SelectedDate)&&(Date<=DatePicker1.SelectedDate)),Date,Ascending)

 

If so,I suggest you try this solution:

1\OnStart:

 

Set(var1,true);Set(var2,true);/*var1 and var2 is my custom variable*/

 

2\set the DatePicker1_1's OnChange property to:

 

Set(var1,false)

 

3\set the DatePicker1's OnChange property to:

 

Set(var2,false)

 

4\set the gallery's items property to:

 

Sort(If(var1 && var2,Filter('[dbo].[TimeSheet]',UserId= MyUser),Filter('[dbo].[TimeSheet]',UserId= MyUser ,(Date>=DatePicker1_1.SelectedDate)&&(Date<=DatePicker1.SelectedDate))),Created,Ascending)

 

Only when the options in both date selectors change, the records in the gallery are filtered according to the date selected by the user.

 Best Regards,

Bof

View solution in original post

Thanks @v-bofeng-msft 

Hello, Sir @v-bofeng-msft 

 

Your Approach is working on my gallery, but when I am removing both the selected dates filter from my gallery, it shows empty.

however it should show all the data of that user when the filter is removed, 

 

I was using the onChange Property on my Date Pickers

 Before DatePicker1_1: OnChange Code:

ClearCollect(Records,Filter('[dbo].[TimeSheet]',Text(Date,"[$-en-US]dd/mm/yyy")=Text(DatePicker1_1.SelectedDate,"[$-en-US]dd/mm/yyy")))


Before DatePicker1: OnChange Code:

ClearCollect(Records,Filter('[dbo].[TimeSheet]',Text(Date,"[$-en-US]dd/mm/yyy")=Text(DatePicker1.SelectedDate,"[$-en-US]dd/mm/yyy")))

 

adasd.png

The Filter remove button code:

 

ClearCollect(Records,'[dbo].[TimeSheet]');
Reset(DatePicker1);Reset(DatePicker1_1)

 


@v-siky-msft 
When User clicks on this filter icon, the date filter should reset and all the data should show up, but it's not working in this 
 Kindly Help!!!

will it work for share point too?

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,532)