Forum Discussion
Create new table applying cartesian logic
- 3 years ago
jeronimo2334 Updated to meet that additional requirement
Place the following M code in a blank query to see the steps for your expected table.
See it all at work in the attached file.
let Source = ExamsT, #"Added Custom" = Table.AddColumn(Source, "Custom", each StudentsT), #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Student"}, {"Student"}), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Custom",{{"Student", type text}}), #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Exam", "Student"}, ResultsT, {"Exam", "Student"}, "ResultsT", JoinKind.LeftOuter), #"Expanded ResultsT" = Table.ExpandTableColumn(#"Merged Queries", "ResultsT", {"Result"}, {"Result"}), #"Replaced Value" = Table.ReplaceValue(#"Expanded ResultsT",null,"Not taken",Replacer.ReplaceValue,{"Result"}), #"Sorted Rows" = Table.Buffer(Table.Sort(#"Replaced Value",{{"Exam", Order.Ascending}, {"Student", Order.Ascending}, {"Result", Order.Descending}})), #"Removed Duplicates" = Table.Distinct(#"Sorted Rows", {"Exam", "Student"}) in #"Removed Duplicates"Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Can the results only be pass or fail?
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Correct.
- AlB3 years agoCommunity Champion
jeronimo2334 Updated to meet that additional requirement
Place the following M code in a blank query to see the steps for your expected table.
See it all at work in the attached file.
let Source = ExamsT, #"Added Custom" = Table.AddColumn(Source, "Custom", each StudentsT), #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Student"}, {"Student"}), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Custom",{{"Student", type text}}), #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Exam", "Student"}, ResultsT, {"Exam", "Student"}, "ResultsT", JoinKind.LeftOuter), #"Expanded ResultsT" = Table.ExpandTableColumn(#"Merged Queries", "ResultsT", {"Result"}, {"Result"}), #"Replaced Value" = Table.ReplaceValue(#"Expanded ResultsT",null,"Not taken",Replacer.ReplaceValue,{"Result"}), #"Sorted Rows" = Table.Buffer(Table.Sort(#"Replaced Value",{{"Exam", Order.Ascending}, {"Student", Order.Ascending}, {"Result", Order.Descending}})), #"Removed Duplicates" = Table.Distinct(#"Sorted Rows", {"Exam", "Student"}) in #"Removed Duplicates"Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
- jeronimo23343 years agoHelper III
Thank you that worked. The pbix seems to be from some other post but the M query is right.
- AlB3 years agoCommunity Champion
Corrected the pbix