cancel
Showing results for
Did you mean:
Helper IV

Find max value in a collection

Hi Everyone,

I have a table with column Name, Group sequence and Account Sequence. I wanted to find the max value in group sequence and account sequence and set it to 0.

Table 1 :

Table 1 after finding the max value and updating it to zero

Regards,

Mahmood

5 REPLIES 5
Memorable Member

You can try below code

Set(getMaxValue,Max(TableName,Column name);

Use

UpdateIf( TableName, columnname=getMaxValue, { ColumnName: 0 } )

Please Mark as answer and give Kudos if its helpful.

Solution Specialist

Try below formula for onselect property of button.

FYI, max is not a delegable function, will not work directly with underlying datasource. That is why I have created collection to avoid delegation issue.

ClearCollect(Test2List, 'Test 2S');
ForAll(Test2List,
UpdateIf('Test 2S', 'Num 1' = Max(Test2List, 'Num 1'), {'Num 1':0},
'Num 2' = Max(Test2List, 'Num 2'), {'Num 2': 0}))

Test 2S is the entity, Num 1 and Num 2 are the columns.

If it answers your question, give kudo and accept it as solution.

Regards,

Prakash

Helper IV

Thanks @rampprakash for your valuable inputs, The above formula will work fine for the third column(Account Sequence) whereas in column 2 ( Group Sequence )we will be getting more than one max value based on the column 3

Memorable Member

Hello @mahmoodhsaud,

Yes in the first variable we will get he Maximum number (Variable will return which is the Maximum number in the column- only one value 0,1,2,3 the output will be 3)

Then based on output we will update the records

UpdateIf( TableName, columnname=getMaxValue, { ColumnName: 0 } )

Let me know if it's not helpful.

Please Mark as answer and give Kudos if its helpful.

Helper IV

Hi @rampprakash ,

In the second column, we need to find the max based on third column. In the below table we will be getting two max value in Group Sequence.

The max value in account sequence 1 is 3 and max value in account sequence 2 is 4. Both should be set to 0.

Announcements

Launching new user group features

Learn how to create your own user groups today!

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,435)