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
johnmelbourne
Helper V
Helper V

Return values from related tables

Hi, I have three related tables in a rather big ERD, and I want to do a test of values in two related tables, and return a value from a third related table,

The best I can explain it is

IF Customer.Name = "Apple Inc" and Location.State = "Kansas" Then Return the value from AnotherRelatedTable.Field

 

OR in psuedo SQL

Select AnotherRelatedTable.Field Where Customer.Name = "Apple Inc" and Location.State = "Kansas" 

 

OR

 

IF TableA.ColumnA = TABLEC.ColumnA and TABLEB.ColumnA = TABLEC.ColumnB then return TABLEC.ColumnC

 

 

Capture.PNG

 

I am new to PBI and am looking around at FILTER, RELATED, CALCULATE, CALCULATETABLE, and am getting abit lost as to how I could effect this.

 

Any assistance would be appreciated

Regards

John

 

1 ACCEPTED SOLUTION
hnguy71
Memorable Member
Memorable Member

Try this:

 

LookMeUp = 
//var LookUpVersion1 = LOOKUPVALUE(Table3[Column2], Table3[Column1], Table1[Column1])
var LookUpVersion2 = CALCULATE(VALUES(Table3[Column2]), FILTER(Table3, Table3[Column1] = Table1[Column1]))
return
CALCULATE(VALUES(Table3[Column3]), FILTER(Table3, Table3[Column2] = LookUpVersion2))

You can use either version 1 or version 2 to get the same result. I'm sure there's a better way to accomplish this



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

1 REPLY 1
hnguy71
Memorable Member
Memorable Member

Try this:

 

LookMeUp = 
//var LookUpVersion1 = LOOKUPVALUE(Table3[Column2], Table3[Column1], Table1[Column1])
var LookUpVersion2 = CALCULATE(VALUES(Table3[Column2]), FILTER(Table3, Table3[Column1] = Table1[Column1]))
return
CALCULATE(VALUES(Table3[Column3]), FILTER(Table3, Table3[Column2] = LookUpVersion2))

You can use either version 1 or version 2 to get the same result. I'm sure there's a better way to accomplish this



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

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.