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

Get the 3 highest numbers for every object of the same category out of an array

Hi Guys.

 

I have a Excel-List with Orders for Products of different Supermarkets. The Supermarkets have their own ID "M01", "M02", "S23" etc... And there is a column with Order-Numbers. 

My task now is to filter the List in a way, that it will only return the 3 highest Order numbers per Supermarket.

 

Inputfile (Excel):

[
{
"MarketID":"M001",
"Product": "Jumping-Rope",
"Orders": 128
},
{
"MarketID":"P01",
"Product": "Sausage",
"Orders": 47
},
{
"MarketID":"M001",
"Product": "Gym-Clothing",
"Orders": 512
},
{
"MarketID":"P01",
"Product": "Corndogs",
"Orders": 125
},
{
"MarketID":"M001",
"Product": "Training Weights",
"Orders": 11
},
{
"MarketID":"M001",
"Product": "Boxing Gloves",
"Orders": 250
},
{
"MarketID":"P01",
"Product": "Cheese",
"Orders": 12
},
{
"MarketID":"P01",
"Product": "Bacon",
"Orders": 25
},
{
"MarketID":"P01",
"Product": "Chocolate",
"Orders": 32
}
]

 

 

desired Result:

[
{
"MarketID":"M001",
"Product": "Gym-Clothing",
"Orders": 512
},
{
"MarketID":"M001",
"Product": "Boxing Gloves",
"Orders": 250
},
{
"MarketID":"M001",
"Product": "Jumping-Rope",
"Orders": 128
},
{
"MarketID":"P01",
"Product": "Corndogs",
"Orders": 125
},
{
"MarketID":"P01",
"Product": "Sausage",
"Orders": 47
},
{
"MarketID":"P01",
"Product": "Chocolate",
"Orders": 32
}
]

 

I already successfully tried to sort all the objects with their order number but that is not what I want... I want a JSON with only THREE products PER MarketID with the THREE HIGHEST Orders.

 

Any help is very appreciated! 

Thank you for your help in advance! 

Best Regards Justus

1 REPLY 1
rsaikrishna
Dual Super User
Dual Super User

@jukulu1337 

 

Power Automate does not have an easy way to sort the array of objects. 

You can cast your vote for the desired feature @ https://powerusers.microsoft.com/t5/Power-Automate-Ideas/Sort-Array/idi-p/312043

 

As you are reading the data from Excel, you can use "List Rows present in a table" action as described in the below post:

https://sharepains.com/2020/03/05/sort-an-array-in-power-automate/

 

Note: You need to apply proper filter, sort column and top column fields in the "List Rows Present in a table"

 

Give a try and post your questions.

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (100,424)