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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / variables inside a gal...
Power Apps
Unanswered

variables inside a gallery

(0) ShareShare
ReportReport
Posted on by 58

I'm looking to register students by creating a gallery (done).

The teacher has to press a button saying whether they are present, absent or late.

However, I'm struggling to make the buttons behave independent to each other in each row. Everytime I create a variable it controls all buttons within a gallery.

I'd also like to upload all answers at the end pressing a submit button. Is this possible?

I'd like the buttons to behave like on the video attached. Thank you in advance for any help.

video gallery buttons.gif
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,538 Most Valuable Professional on at

    Hi @jjanowskiRR ,

    The only way you are going to do that is link the button to a field in the gallery, so if you had a Text field called Attendance, you would Patch it (example)

    Patch(
     DataSource,
     ThisItem,
     {Attendance: "Yes"}
    )

    then the Fill of the Yes button

    If(
     ThisItem.Attendance = "Yes",
     Color.DarkGreen,
     Color.YourNormalColor
    )

    So whatever was in Attendance would determine the Fill of the relevant button.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

     

  • jjanowskiRR Profile Picture
    58 on at

    I've made this work here:

     Patch
     (Attendance_3,
     Defaults(Attendance_3), // Create a new entry
     {
     Students: ThisItem.Value,
     status: "Absent"
     }
    )

    However, I'd like the teacher to be able to amend in the gallery for example. If a student is absent at time of register but comes in late I'd like the teacher to be able to amend the value from absent to late but then erase the absent mark and replace with the late in the list. Is this possible?

     

    Thanks for taking the time to answer Warren

     

     

  • WarrenBelz Profile Picture
    154,538 Most Valuable Professional on at

    @jjanowskiRR ,

    Same principle - example on the No button

    Patch(
     Attendance_3,
     ThisItem,
     {status: "Absent"}
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • jjanowskiRR Profile Picture
    58 on at

    just to give an update - I've been unable to make this work as I'm using this formula to ensure I only have one of each student present in the gallery:

    ForAll(Distinct(Attendance_3,Students),Value)

     the gallery doesn't like this and I'm unable to set up any "variables" as it seems to not know which record it is referencing.

     

    Here is how I've set up the list

     

    Student.        Status.        Date

    S1.                 Present.      10/4

    S2.                 Absent.       10/4

    S3.                 Late             10/4

    S1.                 Present.      11/4

    S2.                 Absent.       11/4

    S3.                 Late             11/4

     

    My ultimate aim is to be able to take a register as a teacher but this is proving rather tricky. My work around is having each student as a field.

  • WarrenBelz Profile Picture
    154,538 Most Valuable Professional on at

    @jjanowskiRR ,

    If you want to use the model I am suggesting, you will need to re-think the gallery structure as you are going to need a field for status to be able to both Patch to and also I assume write back to your data source. You could use AddColumns 

    AddColumns(
     Distinct(
     Attendance_3,
     Students
     ),
     "Status",
     "",
     "Date",
     Today()
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 545 Most Valuable Professional

#2
Haque Profile Picture

Haque 314

#3
Kalathiya Profile Picture

Kalathiya 234 Super User 2026 Season 1

Last 30 days Overall leaderboard