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.

View solution in original post

Leone
Regular Visitor

Thank you both, I will try this out!

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 (2,189)