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 / Total length of a colu...
Power Automate
Answered

Total length of a column that is filtered from an array and contains two values

(0) ShareShare
ReportReport
Posted on by 1,712

Hello,

Recently I have created a flow that filters the active cases from Case entity in CRM.

In this entity I have a "Country" column, this column might be the US or Canada.

After I get the data from the filter array, some cases might have these country labels.
My filter array will only look for Status labels that are equals to "Active".

What I want to achieve is the following:

I want to show the count/length total for each country.

For example:

 

Title Country
 
TEST US
TEST2 Canada
TEST3 Canada
TEST4 Canada
TEST5 US

 

The Output of the length will be for example:
The total active cases in the US are 2.
The total active cases in Canada are 3.

Can please someone explains in detail and provide an example of what I should use actions and expressions to achieve the following scenario?

Any help will be greatly appreciated.
Thank you!

Categories:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at

    Hi!

    You already got this info in an array of objects like the one below, and you want to show totals per Country, right?

     

     

     

    [{"Title": "TEST", "Country": "US"},{"Title": "TEST2", "Country": "Canada"}, {"Title": "TEST3", "Country": "Canada"},{"Title": "TEST4", "Country": "Canada"}, {"Title": "TEST5", "Country": "US"}]

     

     

     

    If you always have this two countries, then you just need to filter by each of them and apply length() to the output of each filter to get the totals per country.

     

    But, if the list of countries changes from time to time, I think it is better to build a dynamic dictionary by means of a Select ad iterate thorugh it with an Apply to Each... You have a consolidation example in the following thread

    https://powerusers.microsoft.com/t5/Building-Flows/Consolidated-email-based-on-date-in-excel/m-p/471253#M57145

    In such thread, instead of Country, we are consolidating by Leader email address, and instead of showing Totals per country we are building a sending an email per email address

    Did I understood your requirements properly? If not, please feel free to correct my wrong assumptions

    Thanx!

  • EBMRay Profile Picture
    1,712 on at

    Hello @efialttes ,

    Thanks for the explanation.

     

    Mainly, I don't always have these two countries (But I have given this as an example), I have many countries and each case might contain a different country label as you mentioned in the second option.

     

    The thread you mentioned is very helpful, and I have created the select action and mapped the "Country label" into it and as a result, it returns [{US,Canada...}].

    After I have received the results of the select action I am stuck based on what I should filter to show later in the email the length per country label of the active cases filtered.

    I would be most grateful if you could provide a screenshot of this scenario so I can understand this perfectly.

    Please have a look at this screenshot:

    Capture.PNG
    No need to correct you have understood my scenario. 😉

    Looking forward to your response.

    Thank you!

  • efialttes Profile Picture
    14,756 on at

    Sure!

    Is it OK if I use as Select input the following array format?

     

    [{"Title": "TEST", "Country": "US"},{"Title": "TEST2", "Country": "Canada"}, {"Title": "TEST3", "Country": "Canada"},{"Title": "TEST4", "Country": "Canada"}, {"Title": "TEST5", "Country": "US"}]

    Or you prefer share an example of your current array format?

    Thanx!

     

  • EBMRay Profile Picture
    1,712 on at

    Hi @efialttes ,

     

    Actually, in the select action, we need only to get all the country values that are filtered so we don't need the titles.

    I would be most grateful if you share an example of the country format without titles because, in the end, I will display in the email the total length per country of the active ones.

     

    Looking forward to hearing from you.

    Thank you very much for your time and support!

  • Verified answer
    efialttes Profile Picture
    14,756 on at

    @Julien2 

    Here you are my Flow design. Please note I am using as Select input the array format I suggested in my previous example

    Flow_ConsolidatedCountries_design.png

    The compose at the bottom of my flow is a dummy one, i.e. just to print the final values stored in variable 'currentConsolidatedResults'

     

    Hope this helps

  • efialttes Profile Picture
    14,756 on at

    Hi again!

    Here you are the execution results of my flow:

    Flow_ConsolidatedCountries_execution.png

    Please note these are the partial outputs:

     

    Select outputs:

    [
     {
     "Country": "US"
     },
     {
     "Country": "Canada"
     },
     {
     "Country": "Canada"
     },
     {
     "Country": "Canada"
     },
     {
     "Country": "US"
     }
    ]

     

    Compose ConsolidatedCountries output (once union() did the magin to generate dynamicaly the Dictionary):

    [
     {
     "Country": "US"
     },
     {
     "Country": "Canada"
     }
    ]

     

    Since this output is an array with two objects; Apply to Each iterates twice, one for {"Country": "US"} and one for {"Country": "Canada"}

     

    Hope this helps

  • efialttes Profile Picture
    14,756 on at

    Hi again

    Expression details, step by step:

    Flow_ConsolidatedCountries_design_2.png

     

    Inside the Apply to Each:

    Flow_ConsolidatedCountries_design_4.png

     

    If you need further assistance, please let us know!

  • EBMRay Profile Picture
    1,712 on at

    Hello @efialttes ,

    Thank you very much for providing a detailed flow design.

    I have followed what you did step by step, and after launching the flow, unfortunately, I have an issue in the filter array where I am mapping into it the following:
    Capture1.PNG

    The error message of this filter array:

    Capture.PNG
    The country field type in this entity is "Option Set", in this filter array I have set this country field equals to the country field again.
    (I think the logic is wrong here because they will never be equals).

    Besides, the other actions return the right results as expected please have a look at these screenshots:
    Entire FlowEntire FlowUnionUnionSelectSelect

    What I am doing wrong in the filter array?

    Looking forward to your response.
    Your help is highly appreciated.
    Kind regards,
    Julien

  • efialttes Profile Picture
    14,756 on at

    Hi!

    On Flow Edit mode, please go to 'Filter array 2', click on 'Edit in advanced mode' and share with us the expression that will be shown

    Thanx!

  • efialttes Profile Picture
    14,756 on at

    Wait, wait wait....

    I think the problem is the input you are currently using for "Filter Array 2".

    I would use the output from 'Filter Array' instead

    Hope this helps

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 1,027

#2
Valantis Profile Picture

Valantis 815

#3
Haque Profile Picture

Haque 630

Last 30 days Overall leaderboard