cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pareshm
Level: Powered On

by default view all items and then filter using datepicker.

Hi,

Please help!

On App launch I want to show items in gallery without any filter. If only user wants to filter he can use Datepicker. Button can again remove filter and show all items.

1. sometimes it works perfectly fine.

2. Sometimes ViewAll variable is false on app lauch and I am not able to understand why.

 

I tried doing below things but its not perfect solution.

 

App.OnStart 

Set(ViewAll, true)

 

Gallery.Items

If(ViewAll, Fruit,
Filter( Fruit, Text(Date, DateTimeFormat.LongDate) = Text( DatePicker1.SelectedDate, DateTimeFormat.LongDate))
)

 

Datepicker.OnChange

UpdateContext({ViewAll : false})

 

 

Button.OnSelect

UpdateContext({ViewAll : true})

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: by default view all items and then filter using datepicker.

Hi, 

 

Please refer to teh formula below: 

Formula: Filter(MyCollection,If(!IsBlank(DatePicker2.SelectedDate),Value.Date = DatePicker2.SelectedDate,true))

Screenshot: 

 

MicrosoftTeams-image (18).png

 

Replace "MyCollection" with your data source and use this formula to filter out gallery results based on Date attribute.
 
Also, ensure that the Date Picker's Default Date and InputTextPlaceHolder is empty so that it won't have any existing data and only when a date is selected, the the gallery filters out matching result, else display all the results.

 

Hope it helps!

 

Thanks, 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

5 REPLIES 5
Dual Super User
Dual Super User

Re: by default view all items and then filter using datepicker.

Hi, 

 

Please refer to teh formula below: 

Formula: Filter(MyCollection,If(!IsBlank(DatePicker2.SelectedDate),Value.Date = DatePicker2.SelectedDate,true))

Screenshot: 

 

MicrosoftTeams-image (18).png

 

Replace "MyCollection" with your data source and use this formula to filter out gallery results based on Date attribute.
 
Also, ensure that the Date Picker's Default Date and InputTextPlaceHolder is empty so that it won't have any existing data and only when a date is selected, the the gallery filters out matching result, else display all the results.

 

Hope it helps!

 

Thanks, 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

pareshm
Level: Powered On

Re: by default view all items and then filter using datepicker.

Thanks @yashag2255 

Its not working. Could you please help me to understand whats Value.Date ?

 

date filter.JPG

Community Support Team
Community Support Team

Re: by default view all items and then filter using datepicker.

Hi @pareshm ,

Do you want to display all reocrds from your data source within the Gallery when you load your app, and filter your Gallery Items based on the DatePicker control?

 

Based on the needs that you mentioned, I think it is not necessary to set a global variable to display show all items or filter items.

 

I have made a test on my side, please take a try with the following workaround:

Set the OnStart property of the App control to following:

ClearCollect(CurrentRecords, Fruit)

Set the Items property of the Gallery to following:

CurrentRecords

Add a DatePicker control (DatePicker1), set the DefaultDate property to Blank(). Set the OnChange property to following:

ClearCollect(
             CurrentRecords, 
             Filter(Fruit,  Text(Date, DateTimeFormat.LongDate) = Text(DatePicker1.SelectedDate, DateTimeFormat.LongDate))
)

Add a "Reset" button, set the OnSelect property to following:

ClearCollect(CurrentRecords, Fruit);
Reset(DatePicker1)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
pareshm
Level: Powered On

Re: by default view all items and then filter using datepicker.

Hi @yashag2255 Thanks It working..

Gallery.Items 

Filter( Fruit, If(!IsBlank(DatePicker1.SelectedDate), Text(Date, DateTimeFormat.LongDate) = Text( DatePicker1.SelectedDate, DateTimeFormat.LongDate), true))

 

@v-xida-msftThanks for your solution too. But above function works just fine.

Dual Super User
Dual Super User

Re: by default view all items and then filter using datepicker.

Hi @pareshm , 

 

Instead of Value.Date, you should put the specific attribute of your collection. Refer to the formula below that I have modified based on your scenario. 

 

Filter( Fruit, DateValue(Text(Date, "[$-en-US]dd-mmm-yyyy")) = DateValue(Text(DatePicker2.SelectedDate, "[$-en-US]dd-mmm-yyyy")))

I am referring "Date" in the expression as the attribute for my local collection please change it if it is something different in you case. 

Here, we are doing a type caste to make both the collection atrribute value and the Dropdown  selected value to be in same format so that they can be compared properly.

 

Hope this Helps!

 

Thanks. 

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Kudoed Authors
Users Online
Currently online: 261 members 5,371 guests
Please welcome our newest community members: