cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Leone
Regular Visitor

Showing/Filtering only whole weeks in Gallery (starting Mondays)

Hello there,

 

I have a gallery in which I want to Filter that the current week is shown and all other weeks that follow.

Currently I just filter with  Filter(Source; Datum >= Today()-3) and that works for most of the days but is not really the solution I'm looking for because it will hide Monday when it's Friday. It's a bit an ugly solution and my client would like to see it fixed. Can you guys help me?

 

1. How can I Filter that the view only shows entries from this current week (starting on Monday's)?

2. Bonus question: How can I make this resiliant enough so it accepts missing Mondays (like not filled in holidays/weekends)? 

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Leone ,

Do you use Monday as the first day within a week?

Do you want to filter your records within current week (Monday through Sunday)?

 

If you use Monday as the first day within a week, and you want to filter your records within current week (Monday through Sunday), please consider take a try with the following formula (set the Items property of Gallery to following😞

Filter(
       Source; 
       Datum >= DateAdd(Today(); -Weekday(Today(); StartOfWeek.Monday)+1);
       Datum <= DateAdd(Today(); 7-Weekday(Today(); StartOfWeek.Monday))
) 

The following formula is used to get the first day (Monday) of current week:

DateAdd(Today(); -Weekday(Today(); StartOfWeek.Monday)+1)

The following formula is used to get the last day (Sunday) of current week:

DateAdd(Today(); 7-Weekday(Today(); StartOfWeek.Monday))

 

If you use Sunday as the first day, you need to modify above Filter formula as below:

Filter(
       Source; 
       Datum >= DateAdd(Today(); -Weekday(Today())+1);
       Datum <= DateAdd(Today(); 7-Weekday(Today()))
) 

 

For your second Bonus question, if you want to exclude the holidays/weekends from above current week days (Monday to Sunday), please check and see if the following blog would help in your scenario:

https://powerapps.microsoft.com/hi-in/blog/excluding-weekends-and-holidays-in-date-differences-in-po...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
GarethPrisk
Resident Rockstar
Resident Rockstar

What is your data source?

  • If it's CDS, you could build a View with this exact criteria
  • That view can then act as your filtering criteria

The filter function in your example is non-delegable, so is it safe to assume that delegation is not an issue here?

Either way, set a variable for the Date you are trying to filter from.

Set (
    gblDateFromFilter,
    Today() - Weekday(
        Today(),
        MondayZero
    )
)

That utilizes the Weekday function to determine the Monday for the given week.

v-xida-msft
Community Support
Community Support

Hi @Leone ,

Do you use Monday as the first day within a week?

Do you want to filter your records within current week (Monday through Sunday)?

 

If you use Monday as the first day within a week, and you want to filter your records within current week (Monday through Sunday), please consider take a try with the following formula (set the Items property of Gallery to following😞

Filter(
       Source; 
       Datum >= DateAdd(Today(); -Weekday(Today(); StartOfWeek.Monday)+1);
       Datum <= DateAdd(Today(); 7-Weekday(Today(); StartOfWeek.Monday))
) 

The following formula is used to get the first day (Monday) of current week:

DateAdd(Today(); -Weekday(Today(); StartOfWeek.Monday)+1)

The following formula is used to get the last day (Sunday) of current week:

DateAdd(Today(); 7-Weekday(Today(); StartOfWeek.Monday))

 

If you use Sunday as the first day, you need to modify above Filter formula as below:

Filter(
       Source; 
       Datum >= DateAdd(Today(); -Weekday(Today())+1);
       Datum <= DateAdd(Today(); 7-Weekday(Today()))
) 

 

For your second Bonus question, if you want to exclude the holidays/weekends from above current week days (Monday to Sunday), please check and see if the following blog would help in your scenario:

https://powerapps.microsoft.com/hi-in/blog/excluding-weekends-and-holidays-in-date-differences-in-po...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Leone
Regular Visitor

Thank you both, I will try this out!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,607)