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 Automate / Count Filter Array Items
Power Automate
Unanswered

Count Filter Array Items

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hey Community!

 

I am trying to do what seems like a simple action, but continue to run into trouble.

 

I am using the Get Items action to pull all items from a list that were created "Today".  That part works great.  I am then trying to filter those results to identify the count of each value in a choice column.

 

RipCityNinja_0-1629404947163.png

In this example I continue to get "0" items in the array when there are several items in the list that meet this criteria.  Should I be using an expression instead of just looking for a keyword "Validation"?

 

I am then planning to use length(body('ID_Validation_Items')) to initialize a new variable.

 

I think I'm missing something small here so any help would be much appreciated.

Categories:
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    Yes you can do it @Anonymous , here is how:

     

    Context: 

    Presuming a SharePoint List like this with one Choice Column:

     

    81921-sh-00.png

     

    Based on a test of an Apply to Each and Compose,

     

    81921-sh-01.png

     

     

    you can see that "Choices" column returns something like this:

     

    81921-sh-02.png

     

    Based on the above, accessing only

     

     

    item()['Choices']

     

     from Filter Array, is therefore insufficient. So the solution instead would be:

     

    Solution:

     

    You would want to access the 'Value' inside the column, like this:

     

     

    item()['Choices']['Value']

     

     

    So it would be  like the below:

     

    81921-sh-03.png

     

    To get the length of this, you can then just do this:

     

     

    length(body('Filter_array'))

     

     

    like below:

      

     

    81921-sh-04.png

     

     

    Then according to test, Compose 3 returns the expected value of 2 - since there are indeed two records with "Choice 4" in the SharePoint list:

     

    81921-sh-05.png

     

     

     

     

     

    Check if it helps @Anonymous 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @poweractivate Thank you for your response.

     

    Flow is failing on the Filter array action...

    RipCityNinja_1-1629410449258.png

    I am using Filter Query in the Get Items action to pull only items added on the day the flow runs.  Might this cause complications?

     

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

     

    It is because one or more rows have the Choices column empty, isn't it?

    That is how I can reproduce what you are seeing:

     

    81921-sh-10.png

     

    81921-sh-11.png

     

    Even like this, I was able to make a solution:

    Consider selecting somewhere with ODATA Filter Query like this to exclude the rows with the Choice column left empty or with no value:

     

    Choices ne null

    Where Choices is the name of your column.

    If you already have a filter query there, you can try putting the word and at the end of existing filter query, then the above, so that it still filters by the date range you want and excludes the rows with  no selection for the Choice column.

    Example Below:

     

    81921-sh-choices-ne-null.png

     

    When I do it this way like the above, it worked for me and the error goes away even with a test row with blank Choices column.

     

    Check if it works for you @Anonymous 

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @poweractivate Thanks again for your continued assistance.

     

    I didn't have any empty values in my choice column when experiencing the error.  I do like your approach should something be left empty in the future so I have added this filter.  I continue to experience problems on the Filter Array action.  I have tried this both inside and outside of an Apply to each loop with no success.

     

    Is there another approach to this?  

     

    Thanks

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 Automate

#1
11manish Profile Picture

11manish 307 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 127

Last 30 days Overall leaderboard