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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ronaldt5
Frequent Visitor

Merge Queries

Dear All

 

I would like to merge these two queries based on Product Line and Commodity Name. The Fuzzy option didn't work for me. As you can I have specific text that is identical. Would like help on how I could merge the two queries and have an added column in Query 1 that brings me the Commodity Code in Query 2.

Query 1

ronaldt5_0-1659187934980.png

 

Query 2

ronaldt5_1-1659188002469.png

 

Results should be as follows:

ronaldt5_2-1659188233804.png

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

At threshold level of 0.2, it will match. See the sample code

Query1

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zcw7CoAwEEXRrQxT27kCEdQmKFhKikFfJJCPZNw/ijaC9T3cZeEOUQK44lZOpWkaZ2pSYlt9kpE9Qf0JknWFai4e+hDzgiFHUHOUnMgBG8o/xiN451GUerlHNVt7AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Gender = _t, #"Product line" = _t]),
    #"Merged Queries" = Table.FuzzyNestedJoin(Source, {"Product line"}, Query2, {"Commodity Name"}, "Query2", JoinKind.LeftOuter, [IgnoreCase=true, IgnoreSpace=true, NumberOfMatches=1, Threshold=0.2]),
    #"Expanded Query2" = Table.ExpandTableColumn(#"Merged Queries", "Query2", {"Commodity Code"}, {"Commodity Code"})
in
    #"Expanded Query2"

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

At threshold level of 0.2, it will match. See the sample code

Query1

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Zcw7CoAwEEXRrQxT27kCEdQmKFhKikFfJJCPZNw/ijaC9T3cZeEOUQK44lZOpWkaZ2pSYlt9kpE9Qf0JknWFai4e+hDzgiFHUHOUnMgBG8o/xiN451GUerlHNVt7AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Gender = _t, #"Product line" = _t]),
    #"Merged Queries" = Table.FuzzyNestedJoin(Source, {"Product line"}, Query2, {"Commodity Name"}, "Query2", JoinKind.LeftOuter, [IgnoreCase=true, IgnoreSpace=true, NumberOfMatches=1, Threshold=0.2]),
    #"Expanded Query2" = Table.ExpandTableColumn(#"Merged Queries", "Query2", {"Commodity Code"}, {"Commodity Code"})
in
    #"Expanded Query2"

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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