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 / Remove duplicates from...
Power Automate
Suggested Answer

Remove duplicates from array and get count of the number of items in a table format

(2) ShareShare
ReportReport
Posted on by 599
I have the below array. I need to remove duplicates and get the count of each RBLRefNo in table format as included in screenshot below. The final table should be used to send out an email to CEO. May i know how to achieve this in Power Automate?
 
"RBLRefno": [
                "RBL2600",
                "RBL2113",
                "RBL2600",
                "RBL1473",
                "RBL2144",
                "RBL1473",
                "RBL2600",
                "RBL2600",
                "RBL2600",
                "RBL2600"
            ]
 
 
I have the same question (0)
  • Suggested answer
    CU11021143-0 Profile Picture
    59 on at
    To remove duplicates from your array and get the count of each RBLRefNo in Power Automate:
    1. Store your array in an array variable.
    2. Use a Compose action with:
    3. union(variables('RBLRefno'), variables('RBLRefno'))
      → This gives a unique list.
    4. Add an Apply to each on this unique list.
      Inside the loop:
      • Filter array → filter original array for the current item
      • Append to array variable (Summary):
      • {
      •   "RBLRefNo": "@{items('Apply_to_each')}",
      •   "Count": "@{length(body('Filter_array'))}"
      • }
    5. Use Create HTML Table on the Summary array.
    6. Send the HTML table in the email to the CEO.
  • Suggested answer
    Kalathiya Profile Picture
    1,717 Super User 2026 Season 1 on at
     
    Yes, you can achieve this using Power Automate.
     
    Please follow the steps below:
    #1. Assume the RBLRefNo array is already stored in an array variable or a Compose action. if not, add a Compose action to store it.
    For example, I stored the sample response in a Compose action to use later. My Compose Action Name is: Compose | RBLArray
    #2. Get Unique RBLRefNo for this add a Compose action to get unique values using the union() expression:
    Expression: (Please put this in expression)
    union(outputs('Compose_|_RBLArray'),outputs('Compose_|_RBLArray'))
    //outputs('Compose_|_RBLArray') -  with the name of your variable or Compose action from the previous step.
    #3. Declared variable with array data type. - This will store final data for the table.
     
     
    #3. Loop through each unique value
    - Add Apply to each loop action - Select the output of the Compose action (Get unique compose) as the input. - From Dynamic Selection
     
    #4. Add Filter Array action inside the apply to each loop action

    From: Select the array variable where you stored all RBLRefNo values (or the Compose output).

    Use a condition to filter items equal to the current loop item

    #5. Add Append to array variable action inside the apply to each loop.
    #6. Add compose action to store the style
    (Past below code)
    <style>
      table {
        border-collapse: collapse;
        width: 100%;
        font-family: Arial, sans-serif;
      }
    
      table th, table td {
        border: 1px solid #ddd;
        padding: 8px;
        text-align: left;
      }
    
      table th {
        background-color: #4CAF50;
        color: white;
      }
    
      table tr:nth-child(even) {
        background-color: #f2f2f2;
      }
    
      table tr:hover {
        background-color: #ddd;
      }
    </style>
     
    #7. Add Create HTML Table action
    From: Select the array variable that we have created above
     
    #8. Add Send an email action
     
    Output:
     
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
    ---------------------------------------------------------------------------------

    📩 Need more help? Just mention @Kalathiya and I’ll be happy to assist.

    ✔️ If this answer helped you, please tick “Does this answer your question?” so it can be marked as the Verified Answer.

    💛 A Like always motivates me to keep contributing!

    ​​​​​​​
  • Suggested answer
    Tharusha Jayadeera Profile Picture
    80 on at
     Hi   ,
     
    If this needs to be achieve in Power Automate desktop, I have just implemented a test flow that you can follow as shown below.

     

    If this helped solve your issue, please mark it as ✅ Accepted Answer.
    If you found it useful, a 🩷 Like is always appreciated.

    Thanks,
    Tharusha

  • Chriddle Profile Picture
    8,685 Super User 2026 Season 1 on at
    Slightly reduced, no loops, no variables:
     
    From:
    xpath(
    	xml(
    		addProperty(
    			json('{}'),
    			'Root',
    			addProperty(
    				json('{}'),
    				'Item',
    				outputs('Compose')
    			)
    		)
    	),
    	'//Item[not(preceding-sibling::* = .)]/text()'
    )
    Map No:
    item()
    Map Count:
    xpath(
    	xml(
    		addProperty(
    			json('{}'),
    			'Root',
    			addProperty(
    				json('{}'),
    				'Item',
    				outputs('Compose')
    			)
    		)
    	),
    	concat('count(//Item[.="',item(),'"])')
    )
     
     
  • Kalathiya Profile Picture
    1,717 Super User 2026 Season 1 on at
     
    If this solution helped, please consider marking it as the verified answer so it can help others in the community 😊
    If you still need assistance, feel free to let us know, we’re happy to help!

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 552

#2
Valantis Profile Picture

Valantis 388

#3
11manish Profile Picture

11manish 375

Last 30 days Overall leaderboard