cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
fdurante
New Member

Filter array to get the maximum value among a set of numbers

Hi everyone,

 

this might be a newbie question. I'm currently trying to build a flow which filters an array to get the maximum value among a set of numbers.

The body (result of a series of connectors and operations I did before in the flow) I have to filter is:

 

[
  {
    "year": 2019,
    "objectId": "39aed1d3-22e7-41f4-80a7-98180afd76f9"
  },
  {
    "year": 2018,
    "objectId": "99b17061-b967-4337-8c38-60842780f1b6"
  },
  {
    "year": 2017,
    "objectId": "5b280760-6fd2-404f-93c1-6b5af5b390e8"
  },
  {
    "year": 2016,
    "objectId": "e40be3bc-a632-4c9d-b458-1e6da1aba740"
  }
]

I need to filter the array in order to have only the element with the maximum value of year (in this case, 2019) and its objectId in it. I've tried my best by initializing variables, filtering year by "value equal to max(item()?['year'])" and many other things, but nothing seems to work correctly...

How can I do it?

 

Thank you very much,

FD

 
1 ACCEPTED SOLUTION

Accepted Solutions
fdurante
New Member

Re: Filter array to get the maximum value among a set of numbers

They are a set of dataflows coming from Power BI, but I have already made some changes to the original fields (which were for example some strings, and among them some "string + year" which were then extracted and modified).

By the way, I've followed the solution I found here and it worked fine for me, so the issue is now resolved.

 

Thank you,

FD

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Filter array to get the maximum value among a set of numbers

@fdurante:

 

Can you tell me where your data is coming from?  SharePoint?  I ask becaus it may be easier to filter the data when it is retrieved.

 

Scott

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
fdurante
New Member

Re: Filter array to get the maximum value among a set of numbers

They are a set of dataflows coming from Power BI, but I have already made some changes to the original fields (which were for example some strings, and among them some "string + year" which were then extracted and modified).

By the way, I've followed the solution I found here and it worked fine for me, so the issue is now resolved.

 

Thank you,

FD

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

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!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (8,281)