To expand all lists in a row of lists at the same time without recurring values

0 votes

I was provided with this succinct and helpful code:

let
Source = #table({"A", "B"}, {{ {1,2}, {3,4}} }),
Expanded = List.Accumulate(
    Table.ColumnNames(Source), 
    Source, 
    (state, column) => Table.ExpandListColumn(state, column))
in
Expanded

Which yields the following result:

I don't want recurrent values in previously processed columns as each follow-on column is processed. I would like to get the following result instead:

Is there a simple modification to the given code that will suffice?

Thanks(:

Feb 19, 2019 in Power BI by Shubham
• 13,490 points
6,227 views

1 answer to this question.

0 votes

Can't promise simple, but I have something that will work for sure. 

Objective : You need a code that can combine the columns with an adjusted code so that;

  • lists are zipped 
  • Inner lists are transformed into records

Step 1 : Expand the list column. This results in a column with nested records which are subsequently expanded.

Step 2 : Create some Dummy text columns that are combined in order to generate the base code (Since you can't use combine columns with nested lists).

Step 3 : Eventually, adjust and remove the steps with the dummy columns.

Code :

let
    Source = #table({"A", "B"}, {{ {1,2}, {3,4}} }),
    #"Merged Columns" = Table.CombineColumns(Source,{"A", "B"}, each List.Transform(List.Zip(_), each Record.FromList(_,{"A","B"})),"Merged"),
    #"Expanded Merged" = Table.ExpandListColumn(#"Merged Columns", "Merged"),
    #"Expanded Merged1" = Table.ExpandRecordColumn(#"Expanded Merged", "Merged", {"A", "B"}, {"A", "B"})
in
    #"Expanded Merged1"
answered Feb 19, 2019 by Upasana
• 8,620 points

Related Questions In Power BI

0 votes
1 answer

Calculated column with the sum of values from many columns in a row

Hi, You can create a new column by ...READ MORE

answered Mar 14, 2019 in Power BI by Cherukuri
• 33,030 points
2,688 views
0 votes
0 answers

How to count of category values in a column?

How to count of category values in ...READ MORE

Oct 30, 2019 in Power BI by ch
• 3,450 points
936 views
0 votes
1 answer

How to Toggle Between Two Option and Make it Interact with the rest of the Visualizations in a Report?

Toggling is an action that is achieved ...READ MORE

answered Oct 20, 2020 in Power BI by anonymous
• 65,770 points
1,119 views
0 votes
1 answer

Power Query: Adding a Special Case

Try adding a Group By with Minimum ...READ MORE

answered Dec 27, 2018 in Power BI by Upasana
• 8,620 points
662 views
0 votes
1 answer

Power Query : Adding Columns and Multiple files

The following call, FirstRowAsHeader = Table.PromoteHeaders(TableWithoutHeader) shall replace the ...READ MORE

answered Feb 14, 2019 in Power BI by Upasana
• 8,620 points
1,735 views
0 votes
1 answer

Replace “yes” found in one list with the actual string from another list

Objective : The idea is to use List.Transform twice, ...READ MORE

answered Feb 19, 2019 in Power BI by Upasana
• 8,620 points
821 views
0 votes
1 answer

PowerQuery : How can I reference a cell's value?

You can do so using a named ...READ MORE

answered Feb 27, 2019 in Power BI by Shubham
• 13,490 points
19,601 views
0 votes
1 answer

Dax: Sum of values from many columns in a row

Yes, you can. Try to "Unpivot other columns" ...READ MORE

answered Apr 3, 2019 in Power BI by Upasana
• 8,620 points
10,550 views
0 votes
1 answer

Calculate Time Intersection to Correlate Sequences of Independent Events

I think this solution requires a CROSS JOIN implementation. ...READ MORE

answered Oct 26, 2018 in Power BI by Upasana
• 8,620 points
804 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP