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})
Solved! Go to Solution.
Hi,
Please refer to teh formula below:
Formula: Filter(MyCollection,If(!IsBlank(DatePicker2.SelectedDate),Value.Date = DatePicker2.SelectedDate,true))
Screenshot:
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!
Hi,
Please refer to teh formula below:
Formula: Filter(MyCollection,If(!IsBlank(DatePicker2.SelectedDate),Value.Date = DatePicker2.SelectedDate,true))
Screenshot:
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!
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,
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.
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.
Hi @v-xida-msft ,
I did exactly what you said, but when I click on Reset button, it does not clear the filter, I have to press the button twice.
why it's happening like that?
User | Count |
---|---|
212 | |
94 | |
85 | |
49 | |
38 |
User | Count |
---|---|
271 | |
104 | |
102 | |
60 | |
59 |