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

Problem with filtering Items in gallery

Hello, i have a problem with gallery filter. Now i'm trying to do it with excel, but it doesnt't work if i use sharepoint too. So i have two tables in Excel, first is called Floor1, where data about desks is stored with column Title (Desk 1, Desk 2 etc), and Reservation1, where data about reservations is stored with colums Title (John Doe Desk 1), DeskText (Desk 1, Desk 2, etc), CheckOutFrom (start date) and CheckOutTo (end date). Reservations write to Reservation1 successfully, but filter in my gallery doesn't work correctly. The formula I am using right now for gallery items is: 

Filter(tbFloor1,Not(Title in Filter(tbReservation1,CheckOutFrom >= startTime && CheckOutTo <= endTime || CheckOutFrom <= endTime && CheckOutTo >= endTime).DeskText))

startTime and endTime are variables set on OnSelect property of Continue button after selecting dates in calendar component. In calendar component there is selected Range option. 

Set(selectedDate,Calendar_1.StartDate);
Set(selectedDateEnd,Calendar_1.EndDate);
Set(startTime,DateValue(Text(selectedDate,DateTimeFormat.ShortDate)));
Set(endTime,DateValue(Text(selectedDateEnd,DateTimeFormat.ShortDate)))

 

What is working: when i select one date and reserve it, it doesn't appear in gallery, BUT

1) if i reserve, for example, Desk1 on 1st May, this desk won't show on 1st of May, but also on any date before and after 1st of May, even tho it is free (here i think problem is that when you click once on date on calendar, only CheckOutFrom is written (1/5/2021) and CheckOutTo remains blank. But if i click twice on date, then both CheckOutForm & CheckOutTo are 1/5/2021 and i am able to reserve this desk on other dates. So maybe the question is, is there a way to say to the powerapp, that if only startTime is selcted, then they should be equal with endTime, so it could understand that it is reserved for one day only?

2) If i reserve a range, for example, 3-5 May, even tho the dates will be correctly written in CheckOutFrom 3/5/2021 and CheckOutTo 5/5/2021, i will be able to reserve all these dates, 3,4,5th of May.

 

It is very important for my app, if someone has the answer, please, i will be very grateful! 

 

3 REPLIES 3
RandyHayes
Super User
Super User

@someonenew 

You need to provide parenthesis around sections of your filter to establish the proper logic and order of precedence. 

Please consider changing your Formula to the following:

Filter(tbFloor1,
   !(Title in 
      Filter(tbReservation1, 
          (CheckOutFrom >= startTime && CheckOutTo <= endTime) || 
          (CheckOutFrom <= endTime && CheckOutTo >= endTime)
      ).DeskText
     )
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you, but this doesn't work. I can select same desk after date, but still cannot select the same desk before date and range still doesn't work 😞

RandyHayes
Super User
Super User

@someonenew 

So without scrubbing that formula, in general it is correct.

But you say that values are not getting written to the data for the start or end dates?

So let's focus on statement #1 from your original post.  How are you storing data into tbReservation1 ?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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