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
lklenner
Frequent Visitor

Table Join with duplicate values need advice

Good morning,

 

I have a set of data , however, as you would expect when doing a full join, duplicate values are created for missing rows.  The data is correct, but my question is, what is the best way to remove the duplicate values in eQty so that the totals align?  Is there a good way to do this?

 

Screenshot 2021-09-20 104137.png

 

Thanks in advance

2 REPLIES 2
lklenner
Frequent Visitor

Hi @v-yingjl 

 

Thanks for your response, however, this does not work.  These are two seperate tables that are being joined, with a different order and rows.  Creating new indices and merging on them does not work.

 

Below is what I'm using at the moment.

 

let
    Source = Table.NestedJoin(MBOMLookup,
      {
        "Component",
        "Component unit",
        "Proj",
        "MBOMData.EBOM"
      },
      EBOMLookup,
      {
        "Component",
        "Component unit",
        "Proj",
        "EBOMData.Immediate Parent"
      },
      "EBOMLookup",
      JoinKind.FullOuter
),

 

 

 

 

v-yingjl
Community Support
Community Support

Hi @lklenner ,

One of the join kinds available in the Merge dialog box in Power Query is a full outer join, which brings in all the rows from both the left and right tables.

 

If want to get the expected output, need to add an index column in each table, and then use merge based on Component column and Index column.

 

Example:

vyingjl_1-1632361322887.png

vyingjl_2-1632361330937.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCgq2cjYytrSwNDBQ0lFyNTAwNDfSNTI2NATyDI30gKKxOthUWRjpmlkaWKKrcrQ0MrIASiPMMjQwMzACKQOrigUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Component = _t, Id = _t, eQty = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Component", type text}, {"Id", type text}, {"eQty", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Merged Queries" = Table.NestedJoin(#"Added Index", {"Component", "Index"}, Table2, {"Component", "Index"}, "Table2", JoinKind.FullOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(#"Merged Queries", "Table2", {"Component", "Id", "eQty"}, {"Table2.Component", "Table2.Id", "Table2.eQty"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Table2",{"Index"}),
    #"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Component", Order.Descending}, {"Table2.Component", Order.Descending}}),
    #"Filled Down" = Table.FillDown(#"Sorted Rows",{"Component", "Table2.Component"})
in
    #"Filled Down"

vyingjl_3-1632361366266.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

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