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
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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

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

Top Solution Authors
Top Kudoed Authors
Users online (24,551)