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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Lookup value from one row and return value from a different row

Hello Everyone,

 

This is my first post so apologies if I am posting this in the wrong place. I am also very new to PowerBI so I will try to explain this to the best of my ability 🙂

 

Currently I am trying to build a PBI report that uses 2 SQL tables mainly. 

 

Table 1 has a title column where I have job references and streets, however if you want to find let's say what streets belong to project X, you have a Parentid and cascadeid that connects them. The parentID and cascade are saved separately on table2 which I have been able to lookup them with 2 custom columns on table 1 using the CALCULATE function.

 

Where I am stuck right now is that I want to create another column that looks at the ParentID, finds the same CascadeID on a different line and returns the title, so I can have both the job ref and street on the same row. 

 

This is an example:

These streets all have the Parent ID 720266:

DiogoMartinsCMO_0-1663315939165.png

And the Job Reference match on the cascadeid is this:

DiogoMartinsCMO_1-1663315996593.png

And I want a calculated column that everytime the ParentID check matches the Cascade Check, regardless of the line, returns the Title value of the matched line. It would look a bit like this:

DiogoMartinsCMO_2-1663316317199.png

 

Thanks in advance for all your help

 

Diogo.

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here's my solution.

Table1:

vkalyjmsft_0-1663655807586.png

Table2:

vkalyjmsft_1-1663655828766.png

Create a calculated column in Table1:

Job Reference Check =
LOOKUPVALUE (
    'Table2'[Title],
    'Table2'[Cascade Check], 'Table1'[ParentID Check]
)

Get the correct result.

vkalyjmsft_2-1663655996223.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
petrawiggin
Helper I
Helper I

Hello! 

How would this be done if all the data were in the same table? Example:

KeyYearVendorOutwardReferenceInwardReference
12342020A7890 
23452021A6789 
67892024A 2345
78902024B 1234
99822024B  

I want to look up each OutwardReference in the Key column and then return the year and vendor of the row where it is found. So, the results would look like this:

KeyYearStatusOutwardReferenceInwardReferenceLaterYearLaterStatus
12342020A7890 2024B
23452021A6789 2024A
67892024A 2345  
78902024B 1234  
99822024B    

What is the best way? Thank you.

SECOND EDIT

The way I figured out to do it is to

  1. merge the table against itself
  2. expand the columns I want to compare and to show (year and status)
  3. create conditional columns that...
    1. IF the expanded year column is null returns a null (where the outward reference doesn't match the key of another row, the new columns shouldn't try to do math and return an error)
    2. Otherwise compares the original year column to the expanded year column from the merge and if the expanded one is later then put in that year as the later year
  4. same thing but if the year is later put in that status as the later status
  5. remove the expanded columns and just leave the custom ones

Is there a more efficient way to do this?

v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here's my solution.

Table1:

vkalyjmsft_0-1663655807586.png

Table2:

vkalyjmsft_1-1663655828766.png

Create a calculated column in Table1:

Job Reference Check =
LOOKUPVALUE (
    'Table2'[Title],
    'Table2'[Cascade Check], 'Table1'[ParentID Check]
)

Get the correct result.

vkalyjmsft_2-1663655996223.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello! 

How would this be done if all the data were in the same table? Example:

KeyYearVendorOutwardReferenceInwardReference
12342020A7890 
23452021A6789 
67892024A 2345
78902024B 1234
99822024B  
10012020A2002 
20022020A 1001

I want to look up each OutwardReference in the Key column and then return the year and vendor of the row where it is found.

EDIT

Actually, I realize I also need an IF statement in there: I only want the later year and later status IFF the later year is different from the year. (This is data from JIRA and I only want to know about the status of a cloned ticket if it was cloned into a project with a different year, not if it was cloned into a project in the same year it was created itself.)

So, the results would look like this:

KeyYearStatusOutwardReferenceInwardReferenceLaterYearLaterStatus
12342020A7890 2024B
23452021A6789 2024A
67892024A 2345  
78902024B 1234  
99822024B    
10012020A2002   
20022020A 1001  

What is the best way? Thank you.

lbendlin
Super User
Super User

Welcome to Power BI and to the forums. Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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