cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Sorting an Array in a specific schema (Top 3 List)

Hi Guys,

I want to achieve a specific Sort-Action in MS Flow to Sort my Array objects.

This is my Input-Array:

 

[

{

"Shop_No": "M048",

"Sales_Person": "XYZ",

"Sum_of_Orders": "147",

"Product_ID": "88748"




},

{

"Shop_No": "M048",

"Sales_Person": "ZYX",

"Sum_of_Orders": "110",

"Product_ID": "999991"




},

{

"Shop_No": "M048",

"Sales_Person": "ZZZ",

"Sum_of_Orders": "147",

"Product_ID": "12321"




},

{

"Shop_No": "M048",

"Sales_Person": "Jonas Marcus",

"Sum_of_Orders": "92",

"Product_ID": "1283213"




},

{

"Shop_No": "M048",

"Sales_Person": "Max Muster",

"Sum_of_Orders": "15",

"Product_ID": "213512"




},

{

"Shop_No": "M055",

"Sales_Person": "asdf",

"Sum_of_Orders": "205",

"Product_ID": "182381"




},

{

"Shop_No": "M055",

"Sales_Person": "max maximus",

"Sum_of_Orders": "199",

"Product_ID": "81238"




},

{




"Shop_No": "M055",

"Sales_Person": "max marcus",

"Sum_of_Orders": "24",

"Product_ID": "ASDF"




},

{

"Shop_No": "M055",

"Sales_Person": "asdf",

"Sum_of_Orders": "168",

"Product_ID": "12345"

}

]

 

Now I want to list the "Top 3 best selling Products per Shop". The other entries can be "deleted". So in the End the List should look like this:

 

[

{

"Shop_No": "M048",

"Sales_Person": "XYZ",

"Sum_of_Orders": "147",

"Product_ID": "88748"




},

{

"Shop_No": "M048",

"Sales_Person": "ZZZ",

"Sum_of_Orders": "147",

"Product_ID": "12321"




},

{

"Shop_No": "M048",

"Sales_Person": "ZYX",

"Sum_of_Orders": "110",

"Product_ID": "999991"




},

{

"Shop_No": "M055",

"Sales_Person": "asdf",

"Sum_of_Orders": "205",

"Product_ID": "182381"




},

{

"Shop_No": "M055",

"Sales_Person": "max maximus",

"Sum_of_Orders": "199",

"Product_ID": "81238"




},

{

"Shop_No": "M055",

"Sales_Person": "asdf",

"Sum_of_Orders": "168",

"Product_ID": "12345"

}

]

 

I am able to sort these objects descending, so thats the first step. But how can I achieve that per Shop_No only the 3 with highest "Sum_of_Orders" gets shown?



Thanks in Advance for any help

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Sorting an Array in a specific schema (Top 3 List)

 

Hi @jukulu1337 ,

 

You could refer to the following method to sort an array.

The first method is to create Azure function, please check the article and get more details about it:

https://sharepains.com/2019/07/13/sort-an-array-or-collection-in-microsoft-flow/

 

Another method is using Data operations action in Power Automate to sort an array, please refer to the following blog and see if it helps:

http://johnliu.net/blog/2018/12/how-to-implement-sort-with-microsoft-flow-in-3-actions-within-a-loop

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Highlighted
Community Support
Community Support

Re: Sorting an Array in a specific schema (Top 3 List)

 

Hi @jukulu1337 ,

 

You could refer to the following method to sort an array.

The first method is to create Azure function, please check the article and get more details about it:

https://sharepains.com/2019/07/13/sort-an-array-or-collection-in-microsoft-flow/

 

Another method is using Data operations action in Power Automate to sort an array, please refer to the following blog and see if it helps:

http://johnliu.net/blog/2018/12/how-to-implement-sort-with-microsoft-flow-in-3-actions-within-a-loop

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (7,441)