Forum Discussion
How to evaluate test results from multiple students?
- 4 years ago
Aah, gotcha. Sorry.
Try this instead:
// Call this 'stephAnswers' let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKjRU0lEyVIrVATKNgMwkCNMYyCwpKk2F8ExAEjmJydkQrimQa2mpFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [question = _t, answer = _t]) in Source// Call this 'stephTest' let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKjZU0lEqBBGGSrE6ML4RkEhC4hsDiZKi0lQkIROQkpzE5GwkMVMgYWkJETBCM9cIzVwjmLlpiTnFqUhiIIPLMzJLkMVABhsaQE0yRjPZGM1kY1QXxwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [student = _t, question = _t, answer = _t]), addStudentQ = Table.AddColumn(Source, "studentQ", each Text.Combine({[student], [question]}, "-"), type text) in addStudentQ// Call this 'stephRootTable' let Source = Table.Distinct(Table.SelectColumns(stephTest, "student")), addPossQuestion = Table.AddColumn(Source, "possQuestion", each stephAnswers[question]), expandPossQuestion = Table.ExpandListColumn(addPossQuestion, "possQuestion"), addStudentQ = Table.AddColumn(expandPossQuestion, "studentQ", each Text.Combine({[student], [possQuestion]}, "-"), type text), chgTypes = Table.TransformColumnTypes(addStudentQ,{{"possQuestion", type text}}) in chgTypesApply all three to your model and relate as follows:
stephAnswers[question] > stephRootTable[possQuestion]
stephTest[studentQ] > stephRootTable[studentQ]
Add a new custom column in stephRootTable as follows:
..score = IF(RELATED(stephTest[answer]) = RELATED(stephAnswers[answer]), 1, 0)Chuck it all in a table as follows:
This should be super-scalable as you're combining lower-resource functions of Power Query with the power of relationships to avoid costly PQ joins.
Pete
BA_Pete - Thank you for sharing the solution... This experience has taught me that I have a lot more to learn. For the past year or so, I've been creating charts and transforming the data model using the tool presented in the buttons on the ribbon to calculate what I need. I need to return to my online course and study the section on Measures and Calculated columns and get much deeper knowledge of all the functions that are in M & DAX. Thanks for sharing the code. Now all I need to do is modify the table/column names to suite and switch out the source of my data. You have been a wonderful coach. I'll reply again again after I have made the modifications and confirmed that the solution scales to meet the data I need to use. You've been a great assistance and coach.
- BA_Pete4 years agoSuper User
No problem Steph, any time.
Best of luck with your studies 🙂
Pete