0

In one table I have two columns of linked Parent/Child data which I need to then Merge with a second table.

I need to create an Index column to obtain unique record so I can merge the two tables.

These tables have around 300 000 records each so I need to use Power Query and don't want to use Excel.

I need an index column based on the parent and then re=starts index count for every unique child

Parent   Child  Index needed
123      AAA     1
123      AAA     2
123      BBB     1
234      CCC     1
234      CCC     2
234      CCC     3

Table structure

1

1 Answer 1

1

If your initial table looks like:

Input table

then this code:

let
    initialTable = Table.FromColumns({{"123", "123", "123", "234", "234", "234"}, {"AAA", "AAA" , "BBB", "CCC", "CCC", "CCC"}}, type table [Parent = text, Child = text]),
    grouped = Table.Group(initialTable, {"Parent", "Child"}, {{"toCombine", each Table.AddIndexColumn(_, "Index", 1, 1), type table}}),
    combined = Table.Combine(grouped[toCombine])
in
    combined

should give expected output:

Output table

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.