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.
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?
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,
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.
WarrenBelz
146,745
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,091
Most Valuable Professional