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 / Filter Gallery on date...
Power Apps
Answered

Filter Gallery on date time with today in Dataverse

(1) ShareShare
ReportReport
Posted on by 44

"Event Start Date Time" and "Event End Date Time" are the names of my two columns. I have to display the list of ongoing events after filtering it.

Scenario for Active Events Filter

The start time should exceed the "Event Start Date Time" and "Event Start Date Time" should equal today's date. If the time is 11 AM right now, I have to disregard all events that finished earlier. For instance, 9 AM–10 PM.

 

I must mention the forthcoming occurrences. Since it is currently 11 AM, I must display all of today's events from that point on until whatever time it finishes.

 

I also need to list any events that begin today and conclude tomorrow, such as

It is 7/7/2024 today and 8/7/2024 tomorrow.

As an illustration, the events begin today at 7/7/2024 8:30 PM and end at 8/7/2024 9 AM.

 

My Filter Query 

 

Set(gblDateToday, Today());
Set(gblDateTomorrow, DateAdd(gblDateToday,1,TimeUnit.Days));
ClearCollect(
    collActiveEvents,
    Filter('Events', ('Event Start Date and Time'  >= gblDateToday && 'Event Start Date and Time' < gblDateTomorrow)   && (Status = 'Status (Events)'.Active) )
   
);
   RemoveIf(collActiveEvents, 'Event End Date and Time' < Now());


ClearCollect(
    collActiveEvents1,
    Filter('Events',   ('Event Start Date and Time'  <=   Now()  && 'Event End Date and Time' >=  Now())  && (Status = 'Status (Events)'.Active))
   
);

 RemoveIf(collActiveEvents1, 'Event End Date and Time' < Now());
 
It's working for all the scenario except if any events starts Today after 6:30PM. Both columns are Date & Time Columns and Time zone independent in Dataverse. 
Categories:
  • WarrenBelz Profile Picture
    156,714 Most Valuable Professional on at

    Hi @abdwbg1 ,

    Try this format 

    With(
     {
     _Start: Now(),
     _Next:
     DateAdd(
     Today(),
     1,
     TimeUnit.Days
     ),
     _End: 
     DateAdd(
     Today(),
     2,
     TimeUnit.Days
     )
     },
     ClearCollect(
     collActiveEvents,
     Filter(
     'Events', 
     Status = 'Status (Events)'.Active &&
     'Event Start Date and Time' >= _Start && 
     'Event Start Date and Time' < _Next && 
     'Event End Date and Time' < _End
     )
     )
    );

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • ABDwbg Profile Picture
    44 on at

    Thanks for your response. It's throwing delegation warning. Please find the attached screenshot.   

    abdwbg1_0-1720412244280.png

    Also  this filter not works for events start today and ends tomorrow. 

     

    Please find the Dataverse screenshot. Highlighted in green should be display in gallery and red should not display in gallery.  

    abdwbg1_1-1720412447785.png

    Here is the Dataverse screenshot, please. Green-highlighted content ought to be shown in the gallery, whereas red content shouldn't be shown there.

     

  • WarrenBelz Profile Picture
    156,714 Most Valuable Professional on at

    @abdwbg1 ,

    You can try with Variables - I would have thought it should be Delegable

    UpdateContext(
     {
     varStart: Now(),
     varNext: 
     DateAdd(
     Today(),
     1,
     TimeUnit.Days
     ),
     varEnd: 
     DateAdd(
     Today(),
     2,
     TimeUnit.Days
     )
     }
    );
    ClearCollect(
     collActiveEvents,
     Filter(
     'Events', 
     Status = 'Status (Events)'.Active &&
     'Event Start Date and Time' >= varStart && 
     'Event Start Date and Time' < varNext && 
     'Event End Date and Time' < varEnd
     )
    );

     

    As for the filter, I followed what I thought were your requirements for two Date and Time Fields

    • 'Event Start Date and Time' needs to be on the current day after the current time AND
    • 'Event End Date and Time' needs to be either on the current day or the next day AND
    • Status needs to be Active

    Is any of that incorrect ?

  • ABDwbg Profile Picture
    44 on at

    Hi Thanks for quick reply,

    As per your recent changes my gallery is looks below. Still it's not working since my time now is 10:50AM, "Today's inactive events" should not display since event end time (8:30AM) is already completed. Also I want to display "Todays' post 7pm events" in the gallery.  

    abdwbg1_0-1720415876754.png

     

  • WarrenBelz Profile Picture
    156,714 Most Valuable Professional on at

    @abdwbg1 ,

    I am a bit lost on that one as effectively this line

    'Event Start Date and Time' >= varStart

    where varStart is Now() should not show anything before the current time. You may have a record with the start time after the end time.

  • ABDwbg Profile Picture
    44 on at

    Please check the table below. First four items should come and last row should not display in gallery. 

    abdwbg1_2-1720419730683.png

     

     

     

  • WarrenBelz Profile Picture
    156,714 Most Valuable Professional on at

    @abdwbg1 ,

    If you do this

    ClearCollect(
     collActiveEvents,
     Filter(
     'Events', 
     'Event Start Date and Time' >= Now()
     )
    );

    do you see the bottom item ?

  • ABDwbg Profile Picture
    44 on at

    No its not displaying for this query 

    abdwbg1_0-1720423147348.png

     

  • ABDwbg Profile Picture
    44 on at

    In the table below ("Today's post 7pm events"), the event name appears if I set the event start time to 6 p.m., but it does not appear if the time is 6:30 p.m. My location current time is 12:55PM

    abdwbg1_2-1720423401299.png

     

     

  • WarrenBelz Profile Picture
    156,714 Most Valuable Professional on at

    @abdwbg1 ,

    Sorry but something is wrong here - these are all And() filters, so each one restricts the filter further

    Filter(
     'Events', 
     Status = 'Status (Events)'.Active &&
     'Event Start Date and Time' >= varStart && 
     'Event Start Date and Time' < varNext && 
     'Event End Date and Time' < varEnd
    );

    so it makes no sense that the remaining filters would add any records back in. It sounds to me that you may have a Time Zone difference issue between the data source and the PC.

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard