web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Find max value in a co...
Power Apps
Unanswered

Find max value in a collection

(0) ShareShare
ReportReport
Posted on by 202

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 :

mahmoodhsaud_0-1631095655945.png

 

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

mahmoodhsaud_1-1631095705225.png

 

Thanks in Advance,

 

Regards,

Mahmood

 

I have the same question (0)
  • Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    Hi @mahmoodhsaud,

     

    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.

     

    Subscribe : https://youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA

    Blog : https://microsoftcrmtechie.blogspot.com

  • Prakash4691 Profile Picture
    1,332 on at

    @mahmoodhsaud 

     

    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

  • mahmoodhsaud Profile Picture
    202 on at

    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

  • Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    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.

     

     

     

    Subscribe : https://youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA

     

    Blog : https://microsoftcrmtechie.blogspot.com

  • mahmoodhsaud Profile Picture
    202 on at

    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.

     

    mahmoodhsaud_1-1631169167805.png

     

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard