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
Super User II
Super User II

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (48,543)