web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / CountRows and Filter S...
Power Apps
Answered

CountRows and Filter SharePoint list by choice field and date field by year equal to year now

(0) ShareShare
ReportReport
Posted on by 12

I have found a few posts in this community that explain comparing date fields from SharePoint to PowerApps dates but nothing that could explain why the following formula is not getting the correct count based upon my filter in a SharePoint list view:

Set(
 varCountRowsClosed,
 CountRows(
 Filter(
 RFS,
 HiringJobStatus.Value = "Closed" || HiringJobStatus.Value = "Closed - No Bid" || HiringJobStatus.Value = "Closed - Lost Bid" && Year(Text("Request_x0020_Date",ShortDate)) = Year(Text(Now(),ShortDate))
 )
 )
);
Set(
 varAvgDaysUntilClosed,
 Sum(
 RFS,
 DaysUntilClosed
 )/varCountRowsClosed
)

Request_x0020_Date is a date/time column in SharePoint online list and Now is in PowerApps.  The HiringJobStatus column is a choice field which shouldn't be what mis calculating.  In the second variable set, varAvgDaysUntilClosed, the DaysUntilClosed column is a calculated column.  But the first variable I am setting, varCountRowsClosed, with the Count Rows fx is calculating 441 rows when there should only be 21 according to the count in my view.  I have made so many changes and cannot get it to jive.  Any help is much appreciated.

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,386 Most Valuable Professional on at

    Hi @3MTeam ,

    Try the below - there is some bracketing required on and and/or and you do not need to convert dates to Text to get the Year.

    With(
     {
     wCountClosed:
     CountRows(
     Filter(
     RFS,
     (
     HiringJobStatus.Value = "Closed" || 
     HiringJobStatus.Value = "Closed - No Bid" || 
     HiringJobStatus.Value = "Closed - Lost Bid" 
     ) && 
     Year(Request_x0020_Date) = Year(Now())
     )
     )
     },
     Set(
     varAvgDaysUntilClosed,
     Sum(
     RFS,
     DaysUntilClosed
     ) / wCountClosed
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • 3MTeam Profile Picture
    12 on at

    @WarrenBelz Thank you so much.  I appreciate your in depth knowledge.  It was the parentheses that I somehow missed.  For anyone looking at this for a solution, this worked but I wanted a global variable instead of a context (local) variable so I used the Set function instead of With {wCountClosed: x}.  The reason is that I wanted to see the value of my variable in my gallery and I could not see it there with it being a local variable in the OnStart property of the app.  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard