cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ChhunH
Level: Powered On

How to count records within the current year?

I am trying to see how many records each person has entered for the current year from a sharepoint list. Here is what I have below:

 

"Current Year Count for " & User().FullName & ": " & CountRows( Filter(
Collection1,
Created >= Date(Year(Today()), Year(Today()), 1),
Created < Date(Year(Today()), 1 + Year(Today()), 1), IsMatch( 'Created By'.Email, User().Email)))

 

Please Help! Thank you 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to count records within the current year?

Hi @ChhunH ,

You just need to use Year(Created), then it will return the created year.

Try this formula:

"Current Year Count for " & User().FullName & ": " & CountRows( Filter(Collection1,Year(Created)=Year(Today())))

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
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

5 REPLIES 5
jhall
Level 8

Re: How to count records within the current year?

Weeeelll...copying/pasting your calculation:

Date(Year(Today()), Year(Today()), 1)

...into a label gives:

3/1/2187

...so maybe start there.  Smiley LOL

Community Support Team
Community Support Team

Re: How to count records within the current year?

Hi @ChhunH ,

You just need to use Year(Created), then it will return the created year.

Try this formula:

"Current Year Count for " & User().FullName & ": " & CountRows( Filter(Collection1,Year(Created)=Year(Today())))

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
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

ChhunH
Level: Powered On

Re: How to count records within the current year?

Wow, this method is so much more effective. Thank you! 

 

Here's what I came up with!

 

CountRows( Filter(
Collection1,
Created >= Date(Year(Today()), 1, 1),
Created < Date(Year(Today()), 12, 31), IsMatch( 'Created By'.Email, User().Email)))

ChhunH
Level: Powered On

Re: How to count records within the current year?


@v-yutliu-msft wrote:

Hi @ChhunH ,

You just need to use Year(Created), then it will return the created year.

Try this formula:

"Current Year Count for " & User().FullName & ": " & CountRows( Filter(Collection1,Year(Created)=Year(Today())))

 

Best regards,

Community Support Team _ Phoebe Liu


Will this also work on a table. I have grouped my data by the creator and then I want to count how many each user can submitted how many entries for the year. I have made a gallery to put these two columns in. 

 

GroupBy(AddColumns(Collection1, "UserDisplayName", 'Created By'.DisplayName), "UserDisplayName", "GroupByUsersDisplayName")

 

CountRows( Filter(GroupByUsersDisplayName,Year(Created)=Year(Today())))

 

It seems like it is working, but I just want to make sure. 

jhall
Level 8

Re: How to count records within the current year?

Yes, this will work on a Table (i.e. Collection).  PowerApps essentially treats (for the most part) any complex data type that groups fields together into a Collection and any of the functions you see that do operations on data sources are treating those sources as Collections as well.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 239 members 5,433 guests
Please welcome our newest community members: