
Announcements
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.
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:
{ FieldName: Value } in Patch()Switch() or If() to update MyRatingXThe app involves two main screens:
colAssessmentQuestionsDropdown8 (values: -1, 0, 1, 2, 3, 4, 5)colStudentScoresX is the question numbercolAssessmentQuestions (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())-1, 0, 1, 2, 3, 4, 5gal_StudentScores (Displays Student Scores)colStudentScoresDropdown8 should update the respective MyRatingX column dynamically{ FieldName: "MyRating" & Number }FieldName dynamically inside { FieldName: Value }{ FieldName, Value } inside Table()FieldName as a columnPatchRecord()PatchRecord() as a valid function// ✅ 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:
Patch(){}Split(ThisItem.QuestionNumbersList, ",") → "Result" isn't recognized"0" in Text() functionSwitch() Instead of Dynamic FieldsPatch(
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:
❌ Cons:
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:
Switch()❌ Cons:
MyRatingX column dynamically?{ FieldName: Value }?Switch() or If()?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! 🚀
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}
)
)
);