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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
cran
Helper I
Helper I

Lookup row information of a related id

Hi, 

 

I have a table that has

- col A: unique work ids,

- col B: users assigned to the Id

- col C: related workid. 

 

The related work Id also exists in the main unique work ids in column A as depending on the type of work of the Id in Col A it can may have a related id. 

 

So it looks as below

 

Col A unique idcol b useridcol c relatedid
1aa 
2bb3
3cc1
4dd 

 

How can I add a 4th column that brings through the userid of the relatedid in col C. 

 

As an example, for unique id 2, it's related id is 3, so I would like to bring the userid against 3 (user id cc) against the row that has unique id 2 

 

Hope that makes sense happy to provide more information but unfortunately can't provide actual data. 

 

Thank you 

1 ACCEPTED SOLUTION

@cran 

 

Use LOOKUPVALUE dax function. 

 

Example: col_d_related_userid = LOOKUPVALUE(Table1[col_b_userid], Table1[col_A_unique_id], Table1[col_c_relatedid])

 

document: https://learn.microsoft.com/en-us/dax/lookupvalue-function-dax

 

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


View solution in original post

4 REPLIES 4
cran
Helper I
Helper I

@rubayatyasmin thank you!

rubayatyasmin
Super User
Super User

Hi, @cran 

 

you can accomplish this using a calculated column and the RELATED function.

Here's the step-by-step process:

  1. You first need to create a relationship between col_A_unique_id and col_c_relatedid. In Power BI Desktop, go to "Model" view by clicking on the "Model" icon in the left pane.

  2. Now, drag "col_A_unique_id" to "col_c_relatedid" to create a relationship.

  3. After creating a relationship, go to "Data" view by clicking on the "Data" icon in the left pane.

  4. Select the table and click on "New column" under the "Modeling" tab.

  5. In the formula bar, type the following formula and hit Enter:

col_d_related_userid = RELATED(Table1[col_b_userid])

 

This formula will create a new column named "col_d_related_userid" that pulls the corresponding user id from column B based on the related id in column C. Note that, the RELATED function works only if there's an active direct or indirect relationship between the tables or if col_c_relatedid and col_A_unique_id are in the same table.

 

Remember that, if you have a row in col_c_relatedid that doesn't correspond to any row in col_A_unique_id, Power BI will return an error. This can be handled by using the IF and ISERROR functions to return a blank or some other value when an error occurs. Here's how you could adjust the formula:

 

col_d_related_userid = IFERROR(RELATED(Table1[col_b_userid]), BLANK())

 

This formula will return a blank if the RELATED function returns an error.

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Hi @rubayatyasmin 

 

Thank you for this - I should have mentioned both columns are in the same table. I can't create a relationship between 2 columns in the same table. 

 

Is there another way to calculate this if both columns are in the same table? Of not shoukd I then create a separate calculated table and then do the steps you have outlined above? 

 

Thank you

@cran 

 

Use LOOKUPVALUE dax function. 

 

Example: col_d_related_userid = LOOKUPVALUE(Table1[col_b_userid], Table1[col_A_unique_id], Table1[col_c_relatedid])

 

document: https://learn.microsoft.com/en-us/dax/lookupvalue-function-dax

 

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors