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
jaredj34
Employee
Employee

Lookup Column in related table with a specific value in another column

I am a Power Query newbie and am trying to replicate a VLOOKUP in a one to many relationship.  I have 2 realated tables, Request and AuditLog with RequestCode as the related column.  What I would like to do is add a custom column with the date the Product Child Assigned to the Requests Table.  Is there a simple way to perform this Lookup?  Below is the sample data and some the code I have tried.  Thank you in advance.

 

Request Table

RequestCode                                                                 RequestName                 Date Assigned                       

OE45497.45499Part CreationLookup Value

 

Audit Log Table

ActionDate              Status                             Action                                                          RequestCode

3/4/2021 4:22NewProduct Child CreatedOE45497.45499
3/4/2021 4:22ChildExecutionProduct Child AssignedOE45497.45499
3/4/2021 4:22RequestInProgressProduct Child SubmittedOE45497.45499
3/4/2021 4:23QCInprogressProduct Child Assigned for QCOE45497.45499
3/4/2021 4:23Ready for QCProduct Child ExecutedOE45497.45499
3/5/2021 18:39QC CompleteQC PassOE45497.45499
3/5/2021 18:39QC CompleteRisk-Issue ConfirmationOE45497.45499
6/28/2021 20:57ChildCloseClosed Product ChildOE45497.45499

 

 

 #"Merged Queries" = Table.NestedJoin(#"Sorted Rows", {"RequestCode"}, GetAllChildRequestsAudit, {"RequestCode"}, "GetAllChildRequestsAudit", JoinKind.LeftOuter),
    #"Added Custom" = Table.AddColumn(#"Merged Queries", "Date Assigned", each  Table.SelectRows(GetAllChildRequestsAudit[ActionDate]),(GetAllChildRequestsAudit[Action] = "Product Child Assigned"))
in
    #"Added Custom"

 

 

4 REPLIES 4
watkinnc
Super User
Super User

I tried to be too fancy!

 

You can write it like:

#"Merged Queries" = Table.Join(#"Sorted Rows", {"RequestCode"}, Table.SelectRows(GetAllChildRequestsAudit, each [Action] = "GetAllChildRequestsAudit"),{"RequestCode"}, JoinKind.Inner)

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Thanks again @watkinnc!  I was able to get your suggestion to almost work.  With the Inner Join, just one row showed up on the table but I was expecting 140 from my sample data.  I switched the Join to a Left Outer and got the 140 rows I expected but the ActionDate only populated one of the rows.  

watkinnc
Super User
Super User

You can write it like:

#"Merged Queries" = Table.Join(#"Sorted Rows", {"RequestCode"}, GetAllChildRequestsAudit{[Action = "Product Child Assigned"]}, {"RequestCode"}, "GetAllChildRequestsAudit", JoinKind.Inner)

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

@watkinnc  - Thanks for the response!!  Your code suggestion makes sense but I received an Expression Error.

 

jaredj34_1-1626213466541.png

 

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.

Top Solution Authors
Top Kudoed Authors