Forum Discussion
Table with individual columns with numerical keys and a table with the corresponding description
Hey guys!
I have a table (Global) that has this structure
| Article | Key 1 | Key 2 | Key 3 | Key 4 | Key 5 | Key 6 | Key 7 | Key 8 | Key 9 |
| Metal | 01 | 01 | 88 | 65 | 07 | 77 | AC | BI | KL |
Then I have a second table (Description) this structure:
| Table | Filter | Key | Description |
| Global | AA | 01 | Aluminum |
| Global | AA | 02 | Copper |
| Global | BB | 01 | 1m |
| Global | C1 | 88 | 2mm |
This table contains the specific Information/ description to the corresponding key. For every key exists a specific filter for bot columns: Table and Filter.
The goal is to expand the table "Global" with the description for every key.
The way I am following now is to create several tables of Description to have specific tables for every key. These tables will be then merged to the table Global.
But this approach would create numerous tables.
Is there maybe a simpler way?
- Anonymous5 years ago
I would transpose the Key table, and then merge it to the Global table. But it's important to first make sure that all of the columns are of type text. Also, you must first demote the headers before transposing, or you will lose data.
let
Source = Excel.CurrentWorkbook(){[Name="KeyTable"]}[Content],
#"Demoted Headers" = Table.DemoteHeaders(Source),
#"Transposed Table" = Table.Transpose(#"Demoted Headers"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Metal", type text}, {"Article ", type text}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Metal"}, GlobalTable, {"Key"}, "NewKeyTable", JoinKind.LeftOuter),
#"Expanded NewKeyTable" = Table.ExpandTableColumn(#"Merged Queries", "NewKeyTable", {"Filter", "Key", "Description"}, {"Filter", "Key", "Description"})
in
#"Expanded NewKeyTable"--Nate
3 Replies
- ImkeF
Community Champion
Hi joshua1990 ,
I'm not sure I understand your description and it is difficult without seeing the desired result anyway.
But your Global table looks like it needs an unpivot-other columns on "Article".
Then you could merge with a list of lookup tables and pivot back if needed. - v-kelly-msft
Community Support
Hi joshua1990 ,
Could you pls provide an expected output for us to test?
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
- AnonymousNot applicable
I would transpose the Key table, and then merge it to the Global table. But it's important to first make sure that all of the columns are of type text. Also, you must first demote the headers before transposing, or you will lose data.
let
Source = Excel.CurrentWorkbook(){[Name="KeyTable"]}[Content],
#"Demoted Headers" = Table.DemoteHeaders(Source),
#"Transposed Table" = Table.Transpose(#"Demoted Headers"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Metal", type text}, {"Article ", type text}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Metal"}, GlobalTable, {"Key"}, "NewKeyTable", JoinKind.LeftOuter),
#"Expanded NewKeyTable" = Table.ExpandTableColumn(#"Merged Queries", "NewKeyTable", {"Filter", "Key", "Description"}, {"Filter", "Key", "Description"})
in
#"Expanded NewKeyTable"--Nate