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 / Count Items in SharePo...
Power Apps
Unanswered

Count Items in SharePoint list based on specified criteria

(0) ShareShare
ReportReport
Posted on by 14

I am developing a rather complicated tool using the Power Platform (PBI, Automate and Apps).  The data entry form submits to a SharePoint list and there are a couple of other data sources for querying data that the app uses as well.  I have a need to count the number of items a VISN (a field in the form) has and if the items are Active (another field in the form) and if the value is at 20, not allow the user to submit the form.  I have seen a number of suggestions to use CountIf and Filter functions but nothing I am doing seems to work.  I have attached a Word doc with my screen shots.  The VISN field and the ItemCount fields are what I need to filter by and then I need to count the rows that meet that criteria and force a stop at 20 per visn.

 

I would appreciate any input.

 

Thank you

Categories:
  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @tonyareznor 

     

    Can you please share screenshots? It is easier to understand your goal if you can share your goal visually.

     

    Name of the field and what kind of UI output you would like to achieve.

     

    -I'll be clocking out now but will definitely check your reply tomorrow, or maybe someone can help you soon too.

  • tonyareznor Profile Picture
    14 on at

    I updated my original post with a doc that has screenshots

  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello @tonyareznor 

     

    Your code should probably look like this to count the VISN + On whether active. I'm not sure what your Active column so update that part.

    CountRows(Filter(Readiness,'CDT Staff VISN Number'=[ADD_THE_FIELD_HERE],Active = Active))

     

    On the Submit button DisplayMode property you can set it to something like this to prevent user from submitting.

    If(
    CountRows(Filter(Readiness,'CDT Staff VISN Number'=[ADD_THE_FIELD_HERE],Active = Active)) = 20,
    DisplayMode.Disabled,
    DisplayMode.Edit)

     

    Also, what do you mean by 'force a stop at 20 per visn'?

  • tonyareznor Profile Picture
    14 on at

    the Active field is a checkbox so either true or false.  There are 18 VISNs each VISN should have no more than 20 Active users.

  • tonyareznor Profile Picture
    14 on at

    I got the count to work and drop into a text input and its working correctly using CountRows(Filter(Readiness,'CDT Staff VISN Number:'.Value = "07" && Active = 1)) but that is only 1 VISN and I need to count each VISN.

  • cha_cha Profile Picture
    4,932 Moderator on at

    @tonyareznor 

    where do you put the count numbers? or how do you apply it? can you please highlight it? Sorry, just want to make sure I don't wander with my replies. I'm clocking out now so expect a reply tomorrow.

  • tonyareznor Profile Picture
    14 on at

    right now I am just dumping the value into a text input on the form.  I was uncertain whether to create another field or not. 

    Capture.PNG
  • tonyareznor Profile Picture
    14 on at

    I got it!!! In case someone else has a similar issue here is what I did

    On the field itself CountRows(Filter(Readiness,'CDT Staff VISN Number:'.Value = VISNDD.Selected.Result && Active = 1))

     

    On the submit button IF(DataCardValue15.Text) = "20",
    Disabled, Edit)

     

    I could use some help on the next one though which is essentially the same thing only there is another condition/field involved.  I have attempted the following but it does not work like the one above 

     

    CountRows(Filter(Readiness,'CDT Staff Occupation'.Value = "RN(Med Surg)" &&'CDT Staff VISN Number:'.Value = VISNDD.Selected.Result && Active = "1"))

     

     

  • cha_cha Profile Picture
    4,932 Moderator on at

    @tonyareznor 

     

    Is it showing any error?

  • tonyareznor Profile Picture
    14 on at

    I got them all working now my struggle is to add a Label that will only be visible with an Error message if the fields are at maximum count. Something like this

    On the Visible property - f(And(Value(DataCardValue15.Text) = 20, (DataCardValue31.Text) = 2 || (DataCardValue28.Text) = 2 || (DataCardValue27.Text) = 2 || (DataCardValue26.Text) = 2 || (DataCardValue26.Text) = 2 || (DataCardValue16.Text) = 4 || (DataCardValue7.Text) = 3 || (DataCardValue37.Text) = 3 ||(DataCardValue39.Text) = 1 || (DataCardValue40.Text) = 1, true, false)

     

    The text needs to be something like this "There is already the maximum number of staff entered for this VISN"

    BUT there are like 8 other error possibilities. I tried doing them all in separate labels but the all appear at the same time and not correct

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard