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
nj-matt
Helper I
Helper I

Lookupvalue in Query Editor from other table

I have 2 tables that are transformed before being combined in a 3rd table.

 

In table 1, I have identifed unique IDs and created a column for each with the result set to "YES".

 

Table 2 will always contain more values than table 1 - so essentially I want to identify these YES's from table 1 before removing and combining in table 3.

 

Example -->

 

Table1

Unique_IDYES?
A-12345YES
A-12346YES

 

Table2

Unique_IDTable 1 YES?
A-12343NO
A-12345YES
A-12346YES
A-12347NO

 

From there I would filter out the YES from table 2 before then combining both tables in the next step.

 

How do I do this in power query in Table2?

1 ACCEPTED SOLUTION

Hi  @nj-matt ,

 

Using below M codes:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WctQ1NDI2MVbSUfLzV4rVgQmYAgUiXYORRMwwRMyhmmIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Unique_ID = _t, #"Table 1 YES?" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Unique_ID", type text}, {"Table 1 YES?", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each (let 
currentID = [Unique_ID]
in 
Table.SelectRows(#"Table 1", each [Unique_ID] = currentID))),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"YES?"}, {"Custom.YES?"})
in
    #"Expanded Custom"

And you will see:

v-kelly-msft_0-1613724191376.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@nj-matt not sure what you mean. It will be easier if you share pbix file using one drive/google drive with the expected output. Remove any sensitive information before sharing.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@nj-matt in table2 add a step to filter "Yes" and then append it in table1.

 

Check my latest blog post Improve UX: Show Year in Legend When Using Time Intelligence Measures | PeryTUS IT Solutions  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I would prefer to do this before the merge to avoid duplicate values that will cause issues on subsequent relationships.

Hi  @nj-matt ,

 

Using below M codes:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WctQ1NDI2MVbSUfLzV4rVgQmYAgUiXYORRMwwRMyhmmIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Unique_ID = _t, #"Table 1 YES?" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Unique_ID", type text}, {"Table 1 YES?", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each (let 
currentID = [Unique_ID]
in 
Table.SelectRows(#"Table 1", each [Unique_ID] = currentID))),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"YES?"}, {"Custom.YES?"})
in
    #"Expanded Custom"

And you will see:

v-kelly-msft_0-1613724191376.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? 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.