Skip to main content

Notifications

Community site session details

Community site session details

Session Id : +zgzVEdGvg/Cge9nFaKtjD
Power Apps - Building Power Apps
Answered

Find the MAX in collection, and assign values to another variable

Like (0) ShareShare
ReportReport
Posted on 23 Aug 2023 14:54:04 by Microsoft Employee

I have an SPO List.

I am grabbing this list and putting it in a variable......var_MaxList

There is column called case load.

I want to find the MAX number there and return the entire line into another variable.

So basically, go through the entire collection, find the engineer with the MOST number of cases, and return that to a variable.

Then with that variable I can pull out the different values from SPO.

The other piece is there is a chance that two or more people will have the same amount, so MAX could return three different lines.

I just want it to return the first one found.

  • BCBuizer Profile Picture
    22,038 Super User 2025 Season 1 on 23 Aug 2023 at 15:30:59
    Re: Find the MAX in collection, and assign values to another variable

    Hi @lardo5150 ,

     

    Edit: Good to see you get this sorted 🙂

  • lardo5150 Profile Picture
    Microsoft Employee on 23 Aug 2023 at 15:30:05
    Re: Find the MAX in collection, and assign values to another variable

    I had to use Value(SUMCases) (that is my SPO calculated column) instead of just SUMCases.

    Thanks!

  • lardo5150 Profile Picture
    Microsoft Employee on 23 Aug 2023 at 15:24:10
    Re: Find the MAX in collection, and assign values to another variable

    It is a calcualted column if that makes a difference.

    It is adding two other columns in SPO.

    It is returning something right in the middle (9), when I have someone with 30.

  • BCBuizer Profile Picture
    22,038 Super User 2025 Season 1 on 23 Aug 2023 at 15:22:23
    Re: Find the MAX in collection, and assign values to another variable

    Hi @lardo5150 ,

     

    Can you please share the results? Perhaps the column type is a text, not a number?

  • lardo5150 Profile Picture
    Microsoft Employee on 23 Aug 2023 at 15:17:56
    Re: Find the MAX in collection, and assign values to another variable

    Seems to be returning something right in the middle, not the max for some reason.

  • Verified answer
    BCBuizer Profile Picture
    22,038 Super User 2025 Season 1 on 23 Aug 2023 at 14:57:12
    Re: Find the MAX in collection, and assign values to another variable

    Hi @lardo5150 ,

     

    By sorting the collection by the amount and then taking the first item, you can get the required result:

     

    Set(
    	gblMax,
    	First(
    		Sort(
    			Collection,
    			AmountColumn,
    			SortOrder.Descending
    		)
    	)
    )

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,731 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,075 Most Valuable Professional

Leaderboard
Loading started