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

How to check a list of dates in a collection against a sharepoint list?

Hi,

 

I am trying to compare a list of dates in the PowerApps against a list of dates in a Sharepoint list using Lookup. Below is my app set-up.

 

I have 2 date pickers (start date and end date). 

 

For example, i selected start date as 16/03/2020 and end date as 20/3/2020.

 

I have used a Forall to loop through these 5 dates and check if any of these dates (16/03, 17/03... 20/03) exists in my PublicHolidays list.

 

 

The command is 

ForAll(FirstN(Days,Value(lblNoDays.Text)),
Not(IsBlank(LookUp(PublicHolidays, (Dates) = DateAdd(drpLeaveStartDate.SelectedDate,Value(Title))))))

 

Note: the FirstN command allow me to know how times must i loop through based on how days between start and end date.

 

However the command does not seem to work as it always return all true or all false based on the first date in the collection. 

 

Any help will be appreciated!

 

1.jpg2.jpg

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Sik ,

 

My Days table contain a single column comprising of running number from 0 to 365 so it should tally with what you mentioned.

 

However i managed to resolve my issue. It seem that checking directing against the list does not work properly.

 

I created another collection that pull the number across from Days table and check against the collection. This works! 🙂

 

Thanks!

View solution in original post

2 REPLIES 2
Community Support
Community Support

Hi @TeeTong ,

 

 

The issue I think is caused by 'Title' column in Days, please share more information about Days, Title in your code.

I think the Days should be a Table store number form 0 - +∞. 

I create a collection 'colDays' for the demo, please try this:

 

ClearCollect(colDays,{Title:0},{Title:1},{Title:2},{Title:3},{Title:4}); 
ClearCollect(colResult,ForAll(FirstN(colDays,DateDiff(drpLeaveStartDate.SelectedDate,drpLeaveEndDate.SelectedDate,Days)),Not(IsBlank(LookUp(PublicHolidays, Dates = DateAdd(drpLeaveStartDate.SelectedDate,Value(Title)))))))

 

Sik

 

Hi @Sik ,

 

My Days table contain a single column comprising of running number from 0 to 365 so it should tally with what you mentioned.

 

However i managed to resolve my issue. It seem that checking directing against the list does not work properly.

 

I created another collection that pull the number across from Days table and check against the collection. This works! 🙂

 

Thanks!

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (57,185)