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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
shaebert
Helper III
Helper III

Lookup Between Two Queries

Hello, 

 

I am trying to do a lookup between two queries. I am looking to see if the Domain & Campaign ID values in a row from query 1 can be found in Query 2. If true "Yes" else "No." 

 

Thanks for the help!

 

Query 1

FnameLNameCompanyDomainCampaign IDLeadQuote Created?
JohnDoeSmith Incsmith.comID-3532YesYes
JaneDoeWalters LLCwalter.comID-5329YesNo

 

Query 2

Quoate NameCompanyDomainCampaign ID
New UpgradeSmith Manufacturingsmith.comID-3532
RenewalWalters Energywalter.comID-4235
2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @shaebert 

Download this sample PBIX with the code below

This Power Query code should work for you

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFPSUXLJTwWSwbmZJRkKnnnJQHYxiK2XnJ8LZHu66BqbGhsBWZGpxUqxOkBtiXmpcG3hiTklqUXFCj4+zkBeOZiH0AnUaAnTGQsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Fname = _t, LName = _t, Company = _t, Domain = _t, #"Campaign ID" = _t, Lead = _t]),
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Quote Created", each if [Domain] = Query2[Domain]{[Index]} and [Campaign ID] = Query2[Campaign ID]{[Index]} then "Yes" else "No"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    #"Removed Columns"

 

 

quotes.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

Anonymous
Not applicable

Hi @shaebert ,

 

Please try the following formula to add a calculated column:

Quote Created? =
IF (
    [Campaign ID]
        = LOOKUPVALUE ( 'Query 2'[Campaign ID], 'Query 2'[Domain], 'Query 1'[Domain] ),
    "Yes",
    "No"
)

2.22.6.1.PNG

Best Regards,
Eyelyn Qin
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

2 REPLIES 2
Anonymous
Not applicable

Hi @shaebert ,

 

Please try the following formula to add a calculated column:

Quote Created? =
IF (
    [Campaign ID]
        = LOOKUPVALUE ( 'Query 2'[Campaign ID], 'Query 2'[Domain], 'Query 1'[Domain] ),
    "Yes",
    "No"
)

2.22.6.1.PNG

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

PhilipTreacy
Super User
Super User

Hi @shaebert 

Download this sample PBIX with the code below

This Power Query code should work for you

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFPSUXLJTwWSwbmZJRkKnnnJQHYxiK2XnJ8LZHu66BqbGhsBWZGpxUqxOkBtiXmpcG3hiTklqUXFCj4+zkBeOZiH0AnUaAnTGQsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Fname = _t, LName = _t, Company = _t, Domain = _t, #"Campaign ID" = _t, Lead = _t]),
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Quote Created", each if [Domain] = Query2[Domain]{[Index]} and [Campaign ID] = Query2[Campaign ID]{[Index]} then "Yes" else "No"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    #"Removed Columns"

 

 

quotes.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors