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.
Good evening,
I want to merge table 1 and table 2 into 1 overview.
But there is not a normal relation between the 2 tables.
Sources:
Table 1
FileID | Supplier |
LFI223081 | Dunga-dunga |
LFI223747 | Sonac-Gent |
LFI224207 | Trob-Dong |
LFI225815 | Moyp-Ballym |
LFI225820 | Dunga-Dunga |
Table 2
Supplier | active | FFA | PH | NPH | PE | Ni |
Dunga-dunga | no | 5 | 20 | 15 | 39 | 700 |
Sonac-Gent | yes | 1 | 10 | 5 | 20 | 550 |
Trob-Dong | yes | 3 | 50 | 40 | 1 | 20 |
Moyp-Ballym | yes | 6 | 300 | 250 | 35 | 1000 |
Dunga-dunga | yes | 4 | 25 | 10 | 40 | 650 |
New overview
FileID Supplier | FFA | PH | NPH | PE | Ni | |
LFI223081 | Dunga-dunga | 4 | 25 | 10 | 40 | 650 |
LFI223747 | Sonac-Gent | 1 | 10 | 5 | 20 | 550 |
LFI224207 | Trob-Dong | 3 | 50 | 40 | 1 | 20 |
LFI225815 | Moyp-Ballym | 6 | 300 | 250 | 35 | 1000 |
LFI225820 | Dunga-Dunga | 4 | 25 | 10 | 40 | 650 |
What I want:
Combine table 1 and 2.
In table 2 there are a lot lines with the same supplier.
But in table 2 there is only 1 active line per supplier.
So i need to combine the active line and get them as above overview.
Can someone help me with this?
Solved! Go to Solution.
Hello @johnkorten
first you need to filter your second table to delete inactive suppliers. As you want to compare this two columns ignoring the case, you need to add a new column where you filter the second table, ignoring the case. Here an example
let
Table1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nHzNDIyNrAwVNJRcinNS0/UTQGRSrE6MDlzE3OgXHB+XmKyrntqXglCysTIACQVUpSfpOuSn5eOkDG1MDQFyvjmVxboOiXm5FTmIssZGcAtc4FYFgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [FileID = _t, Supplier = _t]),
Table2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcinNS0/UTQGRSjpKeflAwhSIjQyAhCGIZWwJJMwNDJRidaKVgvPzEpN13VPzSoCClanFIEUgbICszdQUojikKD9J1yU/Lx2u1hgkC1JiYgDVaQRR6ptfWaDrlJiTU5kLV2wG0mAAUmgE1mNsCrYJ6hJUd0N0mIDVwtwDtsMM5JZYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Supplier = _t, active = _t, FFA = _t, PH = _t, NPH = _t, PE = _t, Ni = _t]),
FilterTable2 = Table.SelectRows(Table2, each ([active] = "yes")),
JoinTable1WithTable2 = Table.AddColumn
(
Table1,
"Table2",
(row)=> Table.SelectRows(FilterTable2, each if Comparer.OrdinalIgnoreCase([Supplier],row[Supplier])=0 then true else false)
),
#"Expanded Table2" = Table.ExpandTableColumn(JoinTable1WithTable2, "Table2", {"active", "FFA", "PH", "NPH", "PE", "Ni"}, {"active", "FFA", "PH", "NPH", "PE", "Ni"})
in
#"Expanded Table2"
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello @johnkorten
first you need to filter your second table to delete inactive suppliers. As you want to compare this two columns ignoring the case, you need to add a new column where you filter the second table, ignoring the case. Here an example
let
Table1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nHzNDIyNrAwVNJRcinNS0/UTQGRSrE6MDlzE3OgXHB+XmKyrntqXglCysTIACQVUpSfpOuSn5eOkDG1MDQFyvjmVxboOiXm5FTmIssZGcAtc4FYFgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [FileID = _t, Supplier = _t]),
Table2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcinNS0/UTQGRSjpKeflAwhSIjQyAhCGIZWwJJMwNDJRidaKVgvPzEpN13VPzSoCClanFIEUgbICszdQUojikKD9J1yU/Lx2u1hgkC1JiYgDVaQRR6ptfWaDrlJiTU5kLV2wG0mAAUmgE1mNsCrYJ6hJUd0N0mIDVwtwDtsMM5JZYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Supplier = _t, active = _t, FFA = _t, PH = _t, NPH = _t, PE = _t, Ni = _t]),
FilterTable2 = Table.SelectRows(Table2, each ([active] = "yes")),
JoinTable1WithTable2 = Table.AddColumn
(
Table1,
"Table2",
(row)=> Table.SelectRows(FilterTable2, each if Comparer.OrdinalIgnoreCase([Supplier],row[Supplier])=0 then true else false)
),
#"Expanded Table2" = Table.ExpandTableColumn(JoinTable1WithTable2, "Table2", {"active", "FFA", "PH", "NPH", "PE", "Ni"}, {"active", "FFA", "PH", "NPH", "PE", "Ni"})
in
#"Expanded Table2"
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hi @johnkorten
I don't see thelogic of how the Dunga-dunga rows are connetced between the tables. How do I know which row in Table 2 joins to which row in table 1?
Phil
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
48 | |
19 | |
13 | |
11 |