Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
VincentA
New Member

How to retrieve the role of a user from another table

Hi,

 

I have two tables, one containing all users with their properties, including their roles.

The other table is used to record a type of operation done for a user, which has its own properties including the ID of the user who did it.

Both tables are related through the user ID.

 

For a report, I need to display :

User ID - Operator ID - Operator role

 

For the user ID, I use user.id. For operator ID, I use operation.operatorId. Then if I try to use user.role, it displays the role of the user while I want to display the role of the operator.

 

I figured I should add a new column in table operation which would reference the table user and the field role, and that it would display the role of the operator. But I have no idea of how to do that. Can someone help?

 

Thanks

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@VincentA , You can got from 1 to many side

 

new column = related(Table2[role])

 

Many to one

New column = maxx(realtedtable(Table1), Table1[role])

 

refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

View solution in original post

It worked with the LOOKUPVALUE function! Thank you for your videos!

 

What I did :

Column= LOOKUPVALUE(user[role], user[id], operation[operatorId])

View solution in original post

8 REPLIES 8
amitchandak
Super User
Super User

@VincentA , You can got from 1 to many side

 

new column = related(Table2[role])

 

Many to one

New column = maxx(realtedtable(Table1), Table1[role])

 

refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

Sorry, I don't understand what you mean by "one to many"/"many to one"?

I tried using the "RELATED" function since I read it in many posts but none of the examples work, it seems to only accept Power Query functions

Oh, I get it now from your videos. How to use that with a table name that has spaces?"

I'm not getting it, I used the MAXX(RELATEDTABLE part but it always gives the same value. I want the value of the column to be relative to the user ID

It worked with the LOOKUPVALUE function! Thank you for your videos!

 

What I did :

Column= LOOKUPVALUE(user[role], user[id], operation[operatorId])
DataVitalizer
Super User
Super User

Hi @VincentA 

Could you share the headers of both tables, that would make it easier to suggest a solution


Did it work ? 👌Mark it as a solution to help spreading knowledge 👉A kudos would be appreciated

Yes, here it is for user table
id | name | email | etc | role

 

And for the operation table

id | status | protocol | operatorId | userId

userId = the ID of the user for who the operation was done

operatorId = the ID of the user who did the operation

Both ID are related in the source DB to the user table

Hi @VincentA 

You can also acheive your result in Power Query by merging both tables using the column id 



Did it work ? 👌Mark it as a solution to help spreading knowledge 👉A kudos would be appreciated

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.