cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
u4jaanus
Resolver I
Resolver I

Compare properties of JSON to find smallest

Hi,

I am working on flow to retrieve the smallest value of stock of a kit.

i.e. Kit A has components B and C. Stock value for B is 5 and C is 2. Hence sale able qty for Complete KIT A is 2 

my JSON schema below.

 

{
  "product": "IRE1003",
  "lines": {
    "line": [
      {
        "product": "28CI127",
        "description": "100cm Mirror ",
        "key": null,
        "quantity": "1",
        "free": "5",
        "companyonorder": "20.00"
      },
      {
        "product": "E60CI",
        "description": "LED Light",
        "key": null,
        "quantity": "1",
        "free": "17",
        "companyonorder": "0.00"
      }
    ]
  }

 

 

How can I assign the smallest value from objects in Array to another Object.

 

 

Desired Answer
{
  "product": "IRE1003",
  "Stock": "5"
}

 

 

If you can point me to right direction please.

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User
4 REPLIES 4
Paulie78
Super User
Super User

Expiscornovus
Super User
Super User

Great solution @Paulie78 🙂

 

Btw, I think in that last compose you are collecting the individual product id and not the product kit number.

 

I believe that expression should be: 

outputs('Compose')['product']

 

Paulie78
Super User
Super User

@Expiscornovus  oh yeah, thanks for the correction and compliment. 👍

It was actually an interesting question to try out. I did it once and it had an apply each loop. I wanted a solution with no loops!

Thanks Paulie,

Didn't realise we can use Select operation Mapping this way.

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (4,403)