Relationship approach

MooseWinooski

New Member
Joined
Aug 1, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Hello all,

Its been some time since I have used PBI so im a little dusty and I can't think my way through to a solution...

I have 2 excel files that contain related data and I want to setup a relationship to them... The 2 columns I have are very very similar and mostly only differ in formatting and also not unique...
example..
Table 1
Animals
CATS DOGS and FISH
HORSES AND PIGS
CATS DOGS and FISH
LIZARDS
Table 2
Animals
Cats, Dogs & Fish
Pigs and Horses
Pigs and Horses
Lizards

Do I need to create a 3rd table with a key to reconcile the differences? or is there another way?

Regards,
M
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    #"Duplicated Column" = Table.DuplicateColumn(Source, "Animals", "Animals - Copy"),
    #"Uppercased Text" = Table.TransformColumns(#"Duplicated Column",{{"Animals - Copy", Text.Upper, type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Uppercased Text"," AND","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",",","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1"," &","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value2", "tblAddSplit", each List.Sort(Text.Split([#"Animals - Copy"]," "))),
    Source1 = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
    #"Duplicated Column1" = Table.DuplicateColumn(Source1, "Animals", "Animals - Copy"),
    #"Uppercased Text1" = Table.TransformColumns(#"Duplicated Column1",{{"Animals - Copy", Text.Upper, type text}}),
    #"Replaced Value10" = Table.ReplaceValue(#"Uppercased Text1"," AND","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value11" = Table.ReplaceValue(#"Replaced Value10",",","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value21" = Table.ReplaceValue(#"Replaced Value11"," &","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Added Custom1" = Table.AddColumn(#"Replaced Value21", "tblAddSplit", each List.Sort(Text.Split([#"Animals - Copy"]," "))),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "In Table 4?", each if List.PositionOf(#"Added Custom"[tblAddSplit], [tblAddSplit]) >-1 then true else false),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Animals - Copy", "tblAddSplit"})
in
    #"Removed Columns"

pq add column.xlsm
ABCDEFGHIJ
1AnimalsTableAnimalsTableAnimalsTableIn Table 4?
2CATS DOGS and FISHTable4Cats, Dogs & FishTable5Cats, Dogs & FishTable5TRUE
3HORSES AND PIGSTable4Pigs and HorsesTable5Pigs and HorsesTable5TRUE
4CATS DOGS and FISHTable4Pigs and HorsesTable5Pigs and HorsesTable5TRUE
5LIZARDSTable4LizardsTable5LizardsTable5TRUE
6cinch bugs and ManganeseTable5cinch bugs and ManganeseTable5FALSE
7Squids and skatesTable5Squids and skatesTable5FALSE
8
Sheet3
 
Upvote 0
Solution
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    #"Duplicated Column" = Table.DuplicateColumn(Source, "Animals", "Animals - Copy"),
    #"Uppercased Text" = Table.TransformColumns(#"Duplicated Column",{{"Animals - Copy", Text.Upper, type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Uppercased Text"," AND","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",",","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1"," &","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value2", "tblAddSplit", each List.Sort(Text.Split([#"Animals - Copy"]," "))),
    Source1 = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
    #"Duplicated Column1" = Table.DuplicateColumn(Source1, "Animals", "Animals - Copy"),
    #"Uppercased Text1" = Table.TransformColumns(#"Duplicated Column1",{{"Animals - Copy", Text.Upper, type text}}),
    #"Replaced Value10" = Table.ReplaceValue(#"Uppercased Text1"," AND","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value11" = Table.ReplaceValue(#"Replaced Value10",",","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value21" = Table.ReplaceValue(#"Replaced Value11"," &","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Added Custom1" = Table.AddColumn(#"Replaced Value21", "tblAddSplit", each List.Sort(Text.Split([#"Animals - Copy"]," "))),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "In Table 4?", each if List.PositionOf(#"Added Custom"[tblAddSplit], [tblAddSplit]) >-1 then true else false),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Animals - Copy", "tblAddSplit"})
in
    #"Removed Columns"

pq add column.xlsm
ABCDEFGHIJ
1AnimalsTableAnimalsTableAnimalsTableIn Table 4?
2CATS DOGS and FISHTable4Cats, Dogs & FishTable5Cats, Dogs & FishTable5TRUE
3HORSES AND PIGSTable4Pigs and HorsesTable5Pigs and HorsesTable5TRUE
4CATS DOGS and FISHTable4Pigs and HorsesTable5Pigs and HorsesTable5TRUE
5LIZARDSTable4LizardsTable5LizardsTable5TRUE
6cinch bugs and ManganeseTable5cinch bugs and ManganeseTable5FALSE
7Squids and skatesTable5Squids and skatesTable5FALSE
8
Sheet3
wow thats intense....
Thanks!
 
Upvote 0
Or this might be more useful:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    #"Duplicated Column" = Table.DuplicateColumn(Source, "Animals", "Animals - Copy"),
    #"Uppercased Text" = Table.TransformColumns(#"Duplicated Column",{{"Animals - Copy", Text.Upper, type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Uppercased Text"," AND","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",",","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1"," &","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value2", "tblAddSplit", each List.Sort(Text.Split([#"Animals - Copy"]," "))),
    Source1 = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
    #"Duplicated Column1" = Table.DuplicateColumn(Source1, "Animals", "Animals - Copy"),
    #"Uppercased Text1" = Table.TransformColumns(#"Duplicated Column1",{{"Animals - Copy", Text.Upper, type text}}),
    #"Replaced Value10" = Table.ReplaceValue(#"Uppercased Text1"," AND","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value11" = Table.ReplaceValue(#"Replaced Value10",",","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Replaced Value21" = Table.ReplaceValue(#"Replaced Value11"," &","",Replacer.ReplaceText,{"Animals - Copy"}),
    #"Added Custom1" = Table.AddColumn(#"Replaced Value21", "tblAddSplit", each List.Sort(Text.Split([#"Animals - Copy"]," "))),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "In Table4 as:", each if List.PositionOf(#"Added Custom"[tblAddSplit], [tblAddSplit]) >-1 then
         Source[Animals]{List.PositionOf(#"Added Custom"[tblAddSplit], [tblAddSplit])} else "#NA"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Animals - Copy", "tblAddSplit"})
in
    #"Removed Columns"

pq add column.xlsm
ABCDEFGHIJ
1AnimalsTableAnimalsTableAnimalsTableIn Table4 as:
2CATS DOGS and FISHTable4Cats, Dogs & FishTable5Cats, Dogs & FishTable5CATS DOGS and FISH
3HORSES AND PIGSTable4Pigs and HorsesTable5Pigs and HorsesTable5HORSES AND PIGS
4CATS DOGS and FISHTable4Pigs and HorsesTable5Pigs and HorsesTable5HORSES AND PIGS
5LIZARDSTable4LizardsTable5LizardsTable5LIZARDS
6cinch bugs and ManganeseTable5cinch bugs and ManganeseTable5#NA
7Squids and skatesTable5Squids and skatesTable5#NA
8
Sheet3
 
Upvote 0

Forum statistics

Threads
1,223,701
Messages
6,173,914
Members
452,537
Latest member
the little giant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top