cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to count records within own month or week

I need to count number of records dated within the current month or week. Any ideas? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

To retrieve the records in a data source for the current month (where the column that contains the date is called 'RecordDate')

 

Filter(
    dataSourceName,
    RecordDate >= Date(Year(Today()), Month(Today()), 1),
    RecordDate < Date(Year(Today()), 1 + Month(Today()), 1))

To retrieve the records in a data source for the current week (you'd use a different value for the StartOfWeek enumeration if your week starts on a day other than Sunday):

Filter(
    dataSourceName,
    RecordDate >= DateAdd(Today(), 1 - Weekday(Today(), StartOfWeek.Sunday)),
    RecordDate < DateAdd(Today(), 7 + 1 - Weekday(Today(), StartOfWeek.Sunday)))

In both cases, the expression returns the first day of the current month/week, and the first day of the next month/week.

 

View solution in original post

2 REPLIES 2
CarlosFigueira
Power Apps
Power Apps

To retrieve the records in a data source for the current month (where the column that contains the date is called 'RecordDate')

 

Filter(
    dataSourceName,
    RecordDate >= Date(Year(Today()), Month(Today()), 1),
    RecordDate < Date(Year(Today()), 1 + Month(Today()), 1))

To retrieve the records in a data source for the current week (you'd use a different value for the StartOfWeek enumeration if your week starts on a day other than Sunday):

Filter(
    dataSourceName,
    RecordDate >= DateAdd(Today(), 1 - Weekday(Today(), StartOfWeek.Sunday)),
    RecordDate < DateAdd(Today(), 7 + 1 - Weekday(Today(), StartOfWeek.Sunday)))

In both cases, the expression returns the first day of the current month/week, and the first day of the next month/week.

 

View solution in original post

Please be careful that with some data sources the > and < operators will not work with date type columns.

For example with SharePoint or SQL Server.

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 (1,269)