web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change Date Filter to ...
Power Apps
Unanswered

Change Date Filter to include Time Value

(0) ShareShare
ReportReport
Posted on by 473

Currently, in my Gallery, color of Desks are set (Gree/Red) according to their availability
- by checking against the Date selected by user with the Dates of active bookings ('Reservation Details')

Switch(
 LookUp(
 ForAll(
 Filter(
 'Reservation Details',
 Date >= FromDate_Dp.SelectedDate,
 Date <= ToDate_Dp.SelectedDate && 'Booking Status' = 'Booking Status (Reservation Details)'.Booked
 ),
 {
 DeskName: 'Reserved Desk'.Name,
 BookingStatus: Text('Booking Status')
 }
 ),
 DeskName = ThisItem.Name
 ).BookingStatus,
 "Booked",
 Color.Red,
 Color.Green
 )

 
However, there is now 'Time' value implemented.
So instead of only filtering/checking via Date, I have to check Date + Time.

gymcode_0-1708421277064.png

 

Below is the code I tried to modify to include Time, but the results are not correct. 
(Booked Desks are still displayed as available in Green color)

Switch(
 LookUp(
 ForAll(
 Filter(
 'Reservation Details',
 'Start Date Time' >= FromDate_Dp.SelectedDate + Time(Value(FromTimeHour_Ddl.Selected.Value), Value(FromTimeMinutes_Ddl.Selected.Value), 0),
 'End Date Time' <= ToDate_Dp.SelectedDate + Time(Value(ToTimeHour_Ddl.Selected.Value), Value(ToTimeMinutes_Ddl.Selected.Value), 0) && 'Booking Status' = 'Booking Status (Reservation Details)'.Booked
 ),
 {
 DeskName: 'Reserved Desk'.Name,
 BookingStatus: Text('Booking Status')
 }
 ),
 DeskName = ThisItem.Name
 ).BookingStatus,
 "Booked",
 Color.Red,
 Color.Green
 )

 
E.g.
- If a Desk is booked between 9am - 5pm in a day, the Desk should be not available (Red color) if any Date+Time is selected between that period
- If a Desk is booked between 12pm - 6pm across N days, the Desk should not be available (Red color) if any Date+Time is selected between that period



Any help is greatly appreciated.

Categories:
I have the same question (0)
  • Inogic Profile Picture
    1,297 Moderator on at

    Hi @gymcode 

     

    You can try to modify below changes in your formula :

    Switch(
    LookUp(
    ForAll(
    Filter(
    'Reservation Details',
    'Start Date Time' >= FromDate_Dp.SelectedDate + Time(Value(FromTimeHour_Ddl.Selected.Value), Value(FromTimeMinutes_Ddl.Selected.Value), 0) &&
    'End Date Time' <= ToDate_Dp.SelectedDate + Time(Value(ToTimeHour_Ddl.Selected.Value), Value(ToTimeMinutes_Ddl.Selected.Value), 0) &&
    'Booking Status' = 'Booking Status (Reservation Details)'.Booked
    ),
    {
    DeskName: 'Reserved Desk'.Name,
    BookingStatus: Text('Booking Status')
    }
    ),
    DeskName = ThisItem.Name
    ).BookingStatus,
    "Booked",
    Color.Red,
    Color.Green
    )

     

    Thanks!

    Inogic Professional Services

    An expert technical extension for your techno-functional business needs

    Power Platform/Dynamics 365 CRM

    Drop and email at crm@inogic.com

    Service:  http://www.inogic.com/services/ 

    Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

  • ruihaolrh Profile Picture
    473 on at

    Hi @Inogic , thanks for your response. However, I think the formula will not fulfil the criteria. Below is a sample scenario.

     

    Existing Reservations:

    - 26 Feb 12pm - 6pm

    - 27 Feb 9am - 6pm

    - 28 Feb 9am - 3pm

     

    If user tries to book 27 Jan 12pm - 1pm,

     

    In the && conditions, the first condition will fulfil,

     

    'Start Date Time' >= FromDate_Dp.SelectedDate + Time(Value(FromTimeHour_Ddl.Selected.Value), Value(FromTimeMinutes_Ddl.Selected.Value), 0)

     

     

    but the second condition below will be missed, so the Desk will still be shown as available.

     

     'End Date Time' <= ToDate_Dp.SelectedDate + Time(Value(ToTimeHour_Ddl.Selected.Value), Value(ToTimeMinutes_Ddl.Selected.Value), 0)

     


    Below are some permutations that I thought through, but it will also block the Desks if user selects a different day.
    *User is also allowed to select multiple days, but a fixed Start Time and End Time

     

    Existing Reservation : 27 Feb 10am - 6pm
    
    
    + Permutations
    
    1. Reservation 'Start Date Time' on/before Selected 'Start Date Time'
    2. Reservation 'Start Date Time' on/after Selected 'End Date Time'
    
    3. Reservation 'End Date Time' on/before Selected 'End Date Time'
    4. Reservation 'End Date Time' on/after Selected 'End Date Time'
    
    
    + Scenarios to block Desk booking (would also wrongly block out Desks if a different day is selected)
    
    A) 27 Feb 12pm - 5pm
    1. Reservation 'Start Date Time' on/before Selected 'Start Date Time'
    3. Reservation 'End Date Time' on/before Selected 'End Date Time'
    
    B) 27 Feb 9am - 5pm
    2. Reservation 'Start Date Time' on/after Selected 'End Date Time'
    4. Reservation 'End Date Time' on/after Selected 'End Date Time'
    
    C) 27 Feb 12pm - 5pm
    1. Reservation 'Start Date Time' on/before Selected 'Start Date Time'
    4. Reservation 'End Date Time' on/after Selected 'End Date Time'
    
    D) 27 Feb 9am - 6pm
    2. Reservation 'Start Date Time' on/after Selected 'End Date Time'
    3. Reservation 'End Date Time' on/before Selected 'End Date Time'

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 96 Super User 2026 Season 1

Last 30 days Overall leaderboard