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 / [HELP NEEDED] Dynamic ...
Power Apps
Unanswered

[HELP NEEDED] Dynamic Field Updates in PowerApps - Patch() Not Accepting Dynamic Column Names

(1) ShareShare
ReportReport
Posted on by 2

🚨 Summary of Issue

I'm building a PowerApps application for teachers to assess student performance. The goal is to:
✅ Allow teachers to select a rating for each question using a dropdown menu
✅ Dynamically update the correct "MyRatingX" field inside colStudentScores
✅ Ensure the update is mapped to the correct question
Submit all ratings to a SharePoint list

⚠️ Main Problem: PowerApps does not support dynamic field names inside Patch() when trying to update { "MyRating" & Number: Value }. I’ve tried multiple workarounds, but none seem to work.

🛠️ What I’ve Already Tried

I've collaborated extensively with GPT-4 and Claude AI to troubleshoot this issue. While they've provided valuable insights, PowerApps' limitations on dynamic field names in Patch() have made it challenging to find a scalable solution.

📌 Need Help With:

  1. Dynamically updating a specific "MyRatingX" column based on a question number
  2. Handling PowerApps' limitation of { FieldName: Value } in Patch()
  3. Ensuring correct type handling when using Switch() or If() to update MyRatingX
  4. Best way to submit the final scores to a SharePoint list

🛠️ App Overview & Workflow

The app involves two main screens:

📌 Screen 1 - Selecting Assessment Content

  • Teachers pick question categories and descriptors
  • This filters available questions for Screen 2
  • Selected questions are stored in colAssessmentQuestions

📌 Screen 2 - Answering Questions & Storing Scores

  • Teachers assign ratings using Dropdown8 (values: -1, 0, 1, 2, 3, 4, 5)
  • The app needs to store the selected answer inside colStudentScores
  • Each question maps to a "MyRatingX" field, where X is the question number
  • Once all ratings are completed, the data is submitted to a SharePoint list

📋 Collections & Controls

🔹 colAssessmentQuestions (Holds Questions & Ratings)

Field Name Description
Code Question identifier
Descriptor Question description
QuestionNumbersList Comma-separated list of question numbers (e.g., "1,2,3")
MyRatingsList Stores selected ratings

🔹 colStudentScores (Holds Student Scores Before Submission)

Field Name Description
StudentID Unique student identifier
StudentName Name of the student
Class Student's class
Code Question code
Descriptor Question description
MyRating1 - MyRating20 Holds student’s rating for each question

**🔹 Dropdown8 (Rating Selector - OnChange Event Triggers Patch())

  • Values: -1, 0, 1, 2, 3, 4, 5
  • Stores the selected rating for a question

🔹 gal_StudentScores (Displays Student Scores)

  • Shows scores from colStudentScores
  • OnChange of Dropdown8 should update the respective MyRatingX column dynamically

❌ What I’ve Tried (Failed Fixes)

1️⃣ Using { FieldName: "MyRating" & Number }

  • PowerApps does not resolve FieldName dynamically inside { FieldName: Value }

2️⃣ Wrapping { FieldName, Value } inside Table()

  • PowerApps still does NOT interpret FieldName as a column

3️⃣ Using PatchRecord()

  • PowerApps does NOT recognize PatchRecord() as a valid function

🚨 Current Code Attempt (With Errors)

// ✅ Correctly Update the correct MyRatingX field inside colStudentScores
Patch(
colStudentScores,
LookUp(colStudentScores, StudentID = gal_StudentScores.Selected.StudentID),
{
"MyRating" & Text(First(Split(ThisItem.QuestionNumbersList, ",")).Result, "00"):
If(Dropdown8.Selected.Value = -1, Blank(), Dropdown8.Selected.Value)
}
);

🔻 Current Errors:

  1. "MyRating" & Text(...) → Unexpected characters in Patch()
  2. PowerApps does NOT allow dynamic field names inside {}
  3. Split(ThisItem.QuestionNumbersList, ",")"Result" isn't recognized
  4. Incorrect format specifier for "0" in Text() function

🔧 Alternative Approaches (Partial Fixes)

✅ Option 1 - Using Switch() Instead of Dynamic Fields

Patch(
colStudentScores,
LookUp(colStudentScores, StudentID = gal_StudentScores.Selected.StudentID),
Switch(
Value(First(Split(ThisItem.QuestionNumbersList, ","))),
1, {MyRating1: If(Dropdown8.Selected.Value = -1, Blank(), Dropdown8.Selected.Value)},
2, {MyRating2: If(Dropdown8.Selected.Value = -1, Blank(), Dropdown8.Selected.Value)},
3, {MyRating3: If(Dropdown8.Selected.Value = -1, Blank(), Dropdown8.Selected.Value)},
// Continue for all 20 rating fields...
20, {MyRating20: If(Dropdown8.Selected.Value = -1, Blank(), Dropdown8.Selected.Value)}
)
);

Pros:

  • Works within PowerApps' limitations
  • Avoids trying to use dynamic column names

Cons:

  • Inefficient (Requires explicitly writing all 20 cases)

✅ Option 2 - Using With() & If() Instead of Switch()

With(
{ questionNumText: First(Split(ThisItem.QuestionNumbersList, ",")) },
Patch(
colStudentScores,
LookUp(colStudentScores, StudentID = gal_StudentScores.Selected.StudentID),
If(questionNumText = "1", {MyRating1: Dropdown8.Selected.Value},
If(questionNumText = "2", {MyRating2: Dropdown8.Selected.Value},
If(questionNumText = "3", {MyRating3: Dropdown8.Selected.Value},
// Continue for all 20 MyRating fields...
If(questionNumText = "20", {MyRating20: Dropdown8.Selected.Value}, {})))))))))))))))))))
)
);

Pros:

  • More readable than Switch()
  • Handles missing values correctly

Cons:

  • Still requires explicitly writing all 20 cases

🔹 Key Issues & Request for Help

  1. Is there a better way to update the correct MyRatingX column dynamically?
  2. What is the best PowerApps-friendly approach to work around { FieldName: Value }?
  3. How do I ensure correct type handling (Text vs. Number vs. Record) when using Switch() or If()?
  4. What’s the best way to submit this data to a SharePoint list while keeping it structured?

I’ve hit a roadblock and would appreciate any insights from the PowerApps experts in this community. If needed, I can provide screenshots and more details! 🚀

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at
    I will clarify the core issue - quite simply you cannot refer to fields dynamically in Power Apps - one possible reason I believe is that every formula needs to be validated to ensure that every possible output is valid - this is not possible when Power Apps does not know what the input is going to be. You also cannot set a field as a Variable - the text string "FieldName" is not the field FieldName. Also this may save you a bit of code on the Switch statement
    With(
       {
          _Question:
          Value(
             First(
                Split(
                   ThisItem.QuestionNumbersList, 
                   ","
                )
             )
          ),
          _Rating: 
          If(
             Dropdown8.Selected.Value = -1,
             Blank(),
             Dropdown8.Selected.Value
          )
       },
       Patch(
          colStudentScores,
          LookUp(
             colStudentScores, 
             StudentID = gal_StudentScores.Selected.StudentID
          ),
          Switch(
             _Question,
             1, 
             {MyRating1: _Rating},
             2, 
             {MyRating2: _Rating},
             3,
             {MyRating3: _Rating},
             . . . . .
             20,
             {MyRating20: _Rating}
          )
       )
    );
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard