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 with date
Power Apps
Answered

Filter gallery with date

(0) ShareShare
ReportReport
Posted on by 44

Hello,

 

I have a sharepoint list with events. Gallery is showing that event month by month. My code in item property of gallery is:

 

 

With(
 {
 _selectedDate: DateValue(
 "01-" & Text(
 ddMonthFilter.Selected.MonthNumber;
 "00"
 ) & "-" & ddYearFilter.Selected.Value
 )
 };
 SortByColumns(Filter(
 ft_postoje_zakladow_test;
 DateValue(ThisRecord.od_kiedy) >= _firstDayOfMonth;
 DateValue(ThisRecord.do_kiedy) <= _lastDayOfMonth;
 cbxActivityFilter.Selected.Atelier in ThisRecord.Title
 ); "field_1")
)
//.od_kiedy - since when .do_kiedy - until when

 

 

I would like to also include events which are in between two months so  for example i have three events:

ThisRecord.od_kiedy-ThisRecord.do_kiedy

15.05.2023-3.06.2023

8.06.2023-12.06.2023

15.06.2023-3.07.2023

Only middle show in June gallery.

I tried with expanding condition for last/next month serach, but result wasn't sastysifing.

 

 

Filter(
 ft_postoje_zakladow_test;
 DateValue(ThisRecord.od_kiedy) >= _firstDayOfMonth&&DateValue(ThisRecord.do_kiedy) <= DateAdd(_lastDayOfMonth;1;TimeUnit.Months)&&cbxActivityFilter.Selected.Atelier in ThisRecord.Title||DateValue(ThisRecord.od_kiedy) >= DateAdd(_firstDayOfMonth;-1;TimeUnit.Months)&&cbxActivityFilter.Selected.Atelier in ThisRecord.Title
 );
 "field_1")
))

 

 

Best Regards

Michał Borek

Categories:
I have the same question (0)
  • Sundeep_Malik Profile Picture
    6,501 on at

    Hey   @michalborek 

    Try this:

    This should give you what you are looking for:

    With(
     {
     _selectedDate: DateValue(
     "01-" & Text(
     ddMonthFilter.Selected.MonthNumber;
     "00"
     ) & "-" & ddYearFilter.Selected.Value
     ),
     _nextMonthDate: DateAdd(
     DateValue(
     "01-" & Text(
     ddMonthFilter.Selected.MonthNumber;
     "00"
     ) & "-" & ddYearFilter.Selected.Value
     );
     1;
     Months
     ),
     _prevMonthDate: DateAdd(
     DateValue(
     "01-" & Text(
     ddMonthFilter.Selected.MonthNumber;
     "00"
     ) & "-" & ddYearFilter.Selected.Value
     );
     -1;
     Months
     )
     };
     SortByColumns(
     Filter(
     ft_postoje_zakladow_test;
     (DateValue(ThisRecord.od_kiedy) >= _firstDayOfMonth && DateValue(ThisRecord.do_kiedy) <= _nextMonthDate)
     || (DateValue(ThisRecord.od_kiedy) >= _prevMonthDate && DateValue(ThisRecord.do_kiedy) <= _lastDayOfMonth)
     || (DateValue(ThisRecord.od_kiedy) < _firstDayOfMonth && DateValue(ThisRecord.do_kiedy) > _lastDayOfMonth)
     && cbxActivityFilter.Selected.Atelier in ThisRecord.Title
     );
     "field_1"
     )
    )

     I hope this helps 🙂

  • michalborek Profile Picture
    44 on at

    Dear @Sundeep_Malik ,

     

    Thank you for your intrest. I tried your code. Just made small adjustment. (Time unit and filter atelier as one for every condtion.

    With(
     {
     _selectedDate: DateValue(
     "01-" & Text(
     ddMonthFilter.Selected.MonthNumber;
     "00"
     ) & "-" & ddYearFilter.Selected.Value
     );
     _nextMonthDate: DateAdd(
     DateValue(
     "01-" & Text(
     ddMonthFilter.Selected.MonthNumber;
     "00"
     ) & "-" & ddYearFilter.Selected.Value
     );
     1;
     TimeUnit.Months
     );
     _prevMonthDate: DateAdd(
     DateValue(
     "01-" & Text(
     ddMonthFilter.Selected.MonthNumber;
     "00"
     ) & "-" & ddYearFilter.Selected.Value
     );
     -1;
     TimeUnit.Months
     )
     };
     SortByColumns(
     Filter(
     ft_postoje_zakladow_test;
     (DateValue(ThisRecord.od_kiedy) >= _firstDayOfMonth && DateValue(ThisRecord.do_kiedy) <= _nextMonthDate) || (DateValue(ThisRecord.od_kiedy) >= _prevMonthDate && DateValue(ThisRecord.do_kiedy) <= _lastDayOfMonth) || (DateValue(ThisRecord.od_kiedy) < _firstDayOfMonth && DateValue(ThisRecord.do_kiedy) > _lastDayOfMonth);
     cbxActivityFilter.Selected.Atelier in ThisRecord.Title
     );
     "field_1"
     )
    )

    but not every result is good. 

    1. 1.04.2023-1.04.2023 shouldn't display in May, same case in June 18.05.2023-19.05.2023.

    2. In May, one event from 20.05.2023 to 16.06.2023 should be also visable in May. (I'm not sure why it's happening)

    result.jpg

    Do you know meybe how to improve code? 

     

    Thank you in advance

  • Verified answer
    michalborek Profile Picture
    44 on at

    I come by giving extended range and picking the start day or end day in a given month gallery.

     Filter(
     ft_postoje_zakladow_test;
     (DateValue(ThisRecord.od_kiedy) >= _prevMonthDate && DateValue(ThisRecord.do_kiedy) <= _nextMonthDate)&&(Month(DateValue(ThisRecord.od_kiedy))=Month(_firstDayOfMonth)||Month(DateValue(ThisRecord.do_kiedy))=Month(_firstDayOfMonth));
     cbxActivityFilter.Selected.Atelier in ThisRecord.Title

     

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#2
11manish Profile Picture

11manish 205 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard