cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Marcthepunk
Regular Visitor

Get max value in list from selected item

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.

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
WarrenBelz
Super User III
Super User III

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.

v-yutliu-msft
Community Support
Community Support

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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?

Helpful resources

Announcements
PA 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 Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

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

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (48,967)