I have a table like this which stores marks of students in different subjects

| Name | Class | ID | Math | English | Hindi |
|---|---|---|---|---|---|
| Tony | 5 | 1 | 39 | 30 | 30 |
| Andrew | 5 | 2 | 40 | 20 | 20 |
| Mark | 5 | 3 | 40 | 10 | 30 |
and a tabel like this which sets the maximum marks of the subject

| Subject | Max Marks |
|---|---|
| Math | 40 |
| English | 30 |
| Hindi | 30 |
I want to create a excel formula that will return this by calculating the percentage of marks obtained in each subject and grade it accordingly and arranges the data to this

and could generate a excel function using AI which is =LET( Data, Table1, Headers, {"Name","Class","ID","Math","Math Grade","English","English Grade","Hindi","Hindi Grade"}, GradeThresholds, Table2, GetMaxMarks, LAMBDA(Subject, IFERROR(INDEX(Table2[Max Marks], MATCH(Subject, Table2[Subject], 0)), "Subject Not Found") ), Grades, LAMBDA(Score,MaxMarks, IFS( Score / MaxMarks >= 0.9, "A", Score / MaxMarks >= 0.75, "B", Score / MaxMarks >= 0.6, "C", Score / MaxMarks >= 0.5, "D", TRUE, "F" ) ), MathMaxMarks, GetMaxMarks("Math"), EnglishMaxMarks, GetMaxMarks("English"), HindiMaxMarks, GetMaxMarks("Hindi"), MathGrades, Grades(INDEX(Data,,MATCH("Math",Table1[#Headers],0)), MathMaxMarks), EnglishGrades, Grades(INDEX(Data,,MATCH("English",Table1[#Headers],0)), EnglishMaxMarks), HindiGrades, Grades(INDEX(Data,,MATCH("Hindi",Table1[#Headers],0)), HindiMaxMarks), ExpandedTable, HSTACK( INDEX(Data,,MATCH("Name",Table1[#Headers],0)), INDEX(Data,,MATCH("Class",Table1[#Headers],0)), INDEX(Data,,MATCH("ID",Table1[#Headers],0)), INDEX(Data,,MATCH("Math",Table1[#Headers],0)), MathGrades, INDEX(Data,,MATCH("English",Table1[#Headers],0)), EnglishGrades, INDEX(Data,,MATCH("Hindi",Table1[#Headers],0)), HindiGrades ), VSTACK(Headers, ExpandedTable) )
which works perfectly, but i want the formula to be dynamic and adjust itself as to i will be adding new subjects to the tables and don't want to hardcode the subject names into the formula each time I add a new subject.
