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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Returning Unique value...
Power Automate
Unanswered

Returning Unique values and counts

(0) ShareShare
ReportReport
Posted on by 24

Hi, 

I am currently attempting to use Power Automate to go through an excel table/array, and list out each unique value under a certain column I have called "Reason for Return by Contractor", and the counts of how many times each value appears. I have attempted this using apply to each loops but get many errors. Does anyone know how to do this or have done something similar in the past? 

 

Thank you, 

Nikkil

Categories:
I have the same question (0)
  • David_MA Profile Picture
    12,982 Super User 2025 Season 2 on at

    You can try this:

    1. Initiate three variables in your flow (use the names you prefer):
      1. Values of type Array and no initial value
      2. Unique Values of type Array and no initial value
      3. Value Count of type string with a default value of Value,Count@{decodeUriComponent('%0A')}
    2. Follow these with a List rows present in a table action.
    3. Add an Apply to each with the Value output from the List rows present in a table action.
    4. In the Apply to each, add an Append to array variable and populate it with the column that contains the value you want to get a count of.
    5. Add a Set variable action to set the value of Unique Values using the expression, which will return just the unique values: union(variables('Values'),variables('Values'))
    6. Add a second Apply to each and use the Unique Values variable for the output
    7. Inside the second Apply to each, add:
      1. List rows present in a table and add a filter query on the column with the values where it is equal to the Current item from the dynamic content. Be sure to choose the Current item value from the second Apply to each action.
      2. Follow it with an Append to String value on the variable Value Count with the following: @{items('Apply_to_each_Unique_Value')},@{length(outputs('List_rows_present_in_a_table_Unique_Value')?['body/value'])}@{decodeUriComponent('%0A')}
    8. The value count will generate comma separated values.

    Your flow will look like this:

    David_MA_0-1719245851723.png

    David_MA_1-1719245879215.png

    David_MA_2-1719245908840.png

    If you change the variable names, you will need to adjust the flow accordingly. You will also need to adjust the expressions to account for how I renamed actions. The expression decodeUriComponent('%0A') is a line break.

  • claudiovc Profile Picture
    94 on at

    Hi @nikkil 

     

    Please try this

     

    My data:

    tablaExcel.PNG

    complete flow:

    FlowCompleto.PNG

    Flow detaill:

    List rows present in a table

    FlujoDetalle1.PNG

     

    FlujoDetalle2.PNG

    union(body('AllValues'),body('AllValues'))
     
    FlujoDetalle3.PNG
    Initialize varable counts as array
     
    FlujoDetalle4.PNG

     

    FlujoDetalle5.PNG

    items('Aplicar_a_cada_uno')

    item()
     
     
    FlujoDetalle6.PNG
    items('Aplicar_a_cada_uno')
    length(body('Filtrar_matriz'))
     
     
    FlujoDetalle7.PNG

    This las action is for show the output flow

     

    I hope it helps you

     

    Greetings!

     
     

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard