cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

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,

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
Highlighted
Community Champion
Community Champion

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.

Highlighted
Community Support
Community Support

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,

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

Highlighted
Regular Visitor

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?

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,944)