Skip to main content
Community site session details

Community site session details

Session Id : YcNwAdmJzUlm4b4oq0B4Nj
Power Apps - Microsoft Dataverse
Unanswered

How to set Rectangle fill color based on previous and current row of gallery in power apps ?

Like (0) ShareShare
ReportReport
Posted on 2 Apr 2024 06:13:21 by

Suppose I have a gallery with one rectangle and one status label. The gallery has four rows. If the previous row's status is 'approved' and the rectangle is filled with color Orange, then the current row's status is 'approved' and the rectangle will be filled. If the previous row's label status is 'pending' and the current row's status is 'approved', then I want the rectangle to not fill. See in the image, the first row is 'pending' but the others are 'approved' with the rectangle filled. I want the user to restrict step by step when the first row's status is 'pending

mkmaheshKumar_0-1712038196251.png

 

 

Categories:
  • v-yueyun-msft Profile Picture
    on 02 Apr 2024 at 06:32:08
    Re: How to set Rectangle fill color based on previous and current row of gallery in power apps ?

    Hi , @mkmaheshKumar 

    You need to add an index row in your collection.

    This is my test data:

    ClearCollect(col2, {Name: "Himanshu Singh" , Status : "Pending"},{Name: "Mahesh Kumar" , Status : "Approve"} , {Name: "Varun Updhyay" , Status : "Approve"},{Name: "Satyam Pandey" , Status : "Pending"} );
    vyueyunmsft_0-1712039439533.png

    We can use this code to add an index row:

     
    ClearCollect(col3,ForAll(
        Sequence(CountRows(col2),1,1),
        Patch({LineNo:Value},Index(col2,Value))
    ))
    vyueyunmsft_1-1712039475099.png

     

    We can use this code in the rectangle-Fill:

    If( CountIf(  Filter(col3,ThisRecord.LineNo<=ThisItem.LineNo)  , Status<>"Approve") >0 , Color.Gray , Color.Orange)
     
    The result is as follows.
    If the first is Pending:
    vyueyunmsft_2-1712039520432.png

    If the first is Approve:

    vyueyunmsft_3-1712039579576.png

     

     If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

     

     
     
     

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Featured topics

Loading complete