Forum Discussion
Connecting Two Tables w/ Lookup
- 8 years ago
Hi Anonymous,
I am assuming that there can be more than one row with the same Usergroup ID in Learning plans and you essentially want to join Learning Plans and Userlsist on the Usergroup ID. The relationships aren't much help in getting to a solution here but there are other ways. I am not sure if this is really the best solution, but if you want is to create a new table with a join between Learning Plans and Userlist, something like this could be a starting point. Click "New Table" and enter the following (or your edit of the same)
NewTable = VAR LPT =
SELECTCOLUMNS('Learning Plans',
"UG",'Learning Plans'[Usergroup ID],
"Learning Plan",'Learning Plans'[Learning Plan]) RETURN FILTER(CROSSJOIN(Userlist,LPT), Userlist[Usergroup ID] = [UG])IN SELECTCOLUMNS you identify the table you want to select columns from followed by a name for the column and a definition. The reason this is necessary is because the column we want to join on have the same name ([Usergroup ID] in both tables, so all we are doing here is renaming that column. You should include all columns from Learning Plan that you want in the result.
The FILTER statement simply selects all rows in the table resulting from the crossjoin between the SELECTCOLUMNS and the Userlist where the Usergroup ID columns agree.
As I said, not particularly elegant but it gets the job done. I hope somebody can come up with something better.
Thanks for your response - mow700
I tried to create a new column using the syntax you provided, but it didn't work as the related() function wouldn't even recognize the first name column - I also tried relatedtable(), but ran into a similar issue. I'm not sure if this approach will get me the desired result.
The Usergroups table is a reference table that is comprised of 2 columns, 'Usergroup ID' and 'Usergroup'. There are only 13 rows in this table and the plan is to map them to the other 2 tables using the Usergroup ID.
Hi Anonymous,
it is not entirely clear what it is you want to achieve here. UserGroups table has a one to many relationship to both UserList and Learning Plans, which implies there is a many-to-many (implied) relationship between users and learning plans. What is it exactly you are trying to tie together?
It would help if you could give an example of what visual you are trying to create on the dashboard using this data model.