Skip to main content

Notifications

Community site session details

Community site session details

Session Id : xrh758ppMZNTI11t1dRz/5
Power Apps - Building Power Apps
Answered

Get max value in list from selected item

Like (0) ShareShare
ReportReport
Posted on 29 May 2020 05:45:00 by 4

Hello to the community,

 

I need to get the max value from a SharePoint list.

From the form, a drop-down list provides the items to select. The selected item result should be MAX() lookup value from a specific column.

I have tried multiple variations of filters, lookups and sort without success. Any assistance will be appreciated. 

First('SPList').column - produces perfectly the value but without the lookup reference. 

I believe that I have to filter on the drop-down list selected item and search for my last entry on that column. However, I'm embarrass to say that I can't seem to get the syntax correct.

 

This produces an invalid argument type-

First(SortByColumns(Filter('SPList', List=Dropdown1.Selected.Value), Column1, Descending)).Column1

 

Thanks.

  • Marcthepunk Profile Picture
    4 on 29 May 2020 at 14:43:25
    Re: Get max value in list from selected item

    Thanks for the reply.

     

    The syntax is finally correct with the double-quotes on the column name. However I had to use SharePoint's "true" column naming because of a space in the column title.

     

    First(SortByColumns(Filter('SPList', List=Dropdown1.Selected.Value), "Column1", Descending)).Column1

     

    The query is not returning any records though and I believe it has to do with my drop-down list. I did indeed tested the filter query on another column and it works. The thing is that my drop-down list is coming from a SharePoint list lookup (Text) column. This could be the reason why its not returning any records. Any ideas around this? Or do I have to alter/recreate the drop-down list lookup values?

  • Verified answer
    v-yutliu-msft Profile Picture
    on 29 May 2020 at 09:42:56
    Re: Get max value in list from selected item

    Hi @Marcthepunk ,

    Three problems on your original formula:
    1)you need to add "" besides your column name.

    2)Column1's data type 

    3)Could you filter function get right result: Filter('SPList', List=Dropdown1.Selected.Value)

    If your filter function also has problem, please tell me the data type of list field and the drop down's Items.

    I assume that Column1 is number type and the filter function is right, then you just need to make a little change:

    First(SortByColumns(Filter('SPList', List=Dropdown1.Selected.Value), "Column1", Descending)).Column1

     

     

    Here's a doc about sortbycolumns function for your reference:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-sort

     

     

    Best regards,

  • WarrenBelz Profile Picture
    146,745 Most Valuable Professional on 29 May 2020 at 05:55:42
    Re: Get max value in list from selected item

    Hi @Marcthepunk ,

    Are you looking for the Maximum of Column1 (I assume it is a Numeric field)

    Max(
     Filter(
     'SPList', 
     List=Dropdown1.Selected.Value, 
     Column1
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

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…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started
Loading complete