Forum Discussion
rmwwgs
5 years agoFrequent Visitor
Union with conditions
Hi all, I am trying to merge 2 tables but am having trouble getting the outcome I want. I currently have a table showing students Attainment grades, based on subjects, and the report cycles that ...
AlexisOlson
Super User
5 years agoCreating a start schema as amitchandak suggest is the best practice, but it you must do it with a DAX UNION statement, I'd try this:
Unioned =
UNION (
Attainment,
SELECTCOLUMNS (
Attainment,
"cycle", Attainment[cycle],
"student", Attainment[student],
"Subject", Attainment[Subject],
"grade name", "Target",
"grade",
LOOKUPVALUE (
Target[grade],
Target[student], Attainment[student],
Target[Subject], Attainment[Subject]
)
)
)- rmwwgs5 years agoFrequent Visitor
I feel like this is the right way to go, creating a new table that adds the target grades in when it matches the student/subject etc. When I try it though I get an error saying a table of multiple values were supplied where a single value was expected.
- AlexisOlson5 years ago
Super User
Did you define this as a new table? It won't work as a measure or calculated column.
- rmwwgs5 years agoFrequent Visitor
Yeah I put it in as a new table. It seems to be the LOOKUPVALUE() function that it is having trouble with. It works fine if I leave that out, but that it obviously the key part that I need.