cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Removing Items from Collection based on Date Selected

Hi Everyone,

 

I have an interesting scenario that im working through at the moment. A request from a client to setup an app that removes a time slot from a dropdown once it is selected for that day 

 

My thought process was to first gather 

 

1. All the items for that particular day from the data source

2. If time is a match to the time in the collection, remove from collection(therefore removing from dropdown)

 

my concern being this would only be for real time and if the person changed the date it would show those times missing instead of resetting to show all the times available for that day. 

 

Is this possible to do in Powerapps?

 

Thank you,

Dave

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Removing Items from Collection based on Date Selected

Hi @dmedeiros,

 

Could you please share a bit more about your scenario?

Could you please show more details about the Collection that you mentioned?

Further, do you want to filter out the items whose time value matches the time that you selected?

 

I have created a SP list on my side as a data source within my app, the data structure as below:1.JPG

 

 

If you want to remove items from Collection based on selected time value, I think the RemoveIf function could achieve your needs. I have made a test on my side, please take a try with the following workaround:2.JPG

 

3.JPG

 

 

Set the OnVisible property of the first screen to following formula:

ClearCollect(Collection1,'20180825_case1')

Note: The '20180825_case1' represents the SP list within my app.

 

Set the Items property of the Gallery control to following fomrula:

Filter(
Collection1,
Text(Start_x0020_Time,"[$-en-US]mm/dd/yyyy")=Text(DatePicker1.SelectedDate,"[$-en-US]mm/dd/yyyy")
)

Set the Items properyty of the Hour Dropdown (Dropdown control) to following formula:

["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"]

 

Set the Items properyty of the Minute Dropdown (Dropdown control) to following formula:

["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"]

Set the OnChange properyty of the Minute Dropdown (Dropdown control) to following formula:

RemoveIf(Collection1,Text(Start_x0020_Time,"[$-en-US]HH:mm")=HourDropdown.Selected.Value&":"&MinuteDropdown.Selected.Value)

When you select a real time within the Hour Dropdown and Minute Dropdown, the specific items would be removed from the Collection (on my side, it is Collection1).

 

The GIF image as below:Test1.gif

 

 

More details about the RemoveIf function in PowerApps, please check the following article:

RemoveIf function

 

In addition, you could also consider use Filter function to filter out the items whose time value does not match the time that you selected:

Filter(
Collection1,
Text(Start_x0020_Time,"[$-en-US]HH:mm")<>HourDropdown.Selected.Value&":"&MinuteDropdown.Selected.Value
)

Set the Items property of the Gallery control to following formula:

Filter(
Collection1,
Text(Start_x0020_Time,"[$-en-US]mm/dd/yyyy")=Text(DatePicker1.SelectedDate,"[$-en-US]mm/dd/yyyy"),
Text(Start_x0020_Time,"[$-en-US]HH:mm")<>HourDropdown.Selected.Value&":"&MinuteDropdown.Selected.Value
)

 

More detaisl about the Filter function in PowerApps, please check the following article:

Filter function

 

 

Best regards,

Kris

 

 

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.

View solution in original post

1 REPLY 1
Highlighted
Community Support
Community Support

Re: Removing Items from Collection based on Date Selected

Hi @dmedeiros,

 

Could you please share a bit more about your scenario?

Could you please show more details about the Collection that you mentioned?

Further, do you want to filter out the items whose time value matches the time that you selected?

 

I have created a SP list on my side as a data source within my app, the data structure as below:1.JPG

 

 

If you want to remove items from Collection based on selected time value, I think the RemoveIf function could achieve your needs. I have made a test on my side, please take a try with the following workaround:2.JPG

 

3.JPG

 

 

Set the OnVisible property of the first screen to following formula:

ClearCollect(Collection1,'20180825_case1')

Note: The '20180825_case1' represents the SP list within my app.

 

Set the Items property of the Gallery control to following fomrula:

Filter(
Collection1,
Text(Start_x0020_Time,"[$-en-US]mm/dd/yyyy")=Text(DatePicker1.SelectedDate,"[$-en-US]mm/dd/yyyy")
)

Set the Items properyty of the Hour Dropdown (Dropdown control) to following formula:

["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"]

 

Set the Items properyty of the Minute Dropdown (Dropdown control) to following formula:

["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"]

Set the OnChange properyty of the Minute Dropdown (Dropdown control) to following formula:

RemoveIf(Collection1,Text(Start_x0020_Time,"[$-en-US]HH:mm")=HourDropdown.Selected.Value&":"&MinuteDropdown.Selected.Value)

When you select a real time within the Hour Dropdown and Minute Dropdown, the specific items would be removed from the Collection (on my side, it is Collection1).

 

The GIF image as below:Test1.gif

 

 

More details about the RemoveIf function in PowerApps, please check the following article:

RemoveIf function

 

In addition, you could also consider use Filter function to filter out the items whose time value does not match the time that you selected:

Filter(
Collection1,
Text(Start_x0020_Time,"[$-en-US]HH:mm")<>HourDropdown.Selected.Value&":"&MinuteDropdown.Selected.Value
)

Set the Items property of the Gallery control to following formula:

Filter(
Collection1,
Text(Start_x0020_Time,"[$-en-US]mm/dd/yyyy")=Text(DatePicker1.SelectedDate,"[$-en-US]mm/dd/yyyy"),
Text(Start_x0020_Time,"[$-en-US]HH:mm")<>HourDropdown.Selected.Value&":"&MinuteDropdown.Selected.Value
)

 

More detaisl about the Filter function in PowerApps, please check the following article:

Filter function

 

 

Best regards,

Kris

 

 

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.

View solution in original post

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,476)