Creating value lists with multiple values in same cell

Copper Contributor

I need to create value lists for fields from large tables of data where there are multiple values within the same cell separate by ";". The data is contained in the table as follows:

 

 Column 1Column 2Column 3
Row 1Value1;Value2;Value3ValueAValuei;Valueii
Row 2Value1ValueA;ValueB;ValueCValuei;Valueii;Valueiii
Row 3Value1;Value4;Value5ValueB;ValueDValueiii;Valueiv
Row 4Value2;Value6ValueD;ValueEValueiv;Valuev
Row 5Value3;Value7ValueFValuevi

 

And I wish to generate the following value lists:

 

Column 1 Value ListColumn 2 Value ListColumn 3 Value List
Value1ValueAValuei
Value2ValueBValueii
Value3ValueCValueiii
Value4ValueDValueiv
Value5ValueEValuev
Value6ValueFValuevi
Value7  

 

Is there a way to do this without disrupting the original data table. Originally I thought I might be able to delimit the data within Pivot Tables, but inquiries I've made so far indicate that the data needs to be delimited first before generating the Pivot Table.

 

Does anyone have any proposed solutions?

 

Thanks in advance.

1 Reply

@pacecar81 

That could be done by Power Query.

image.png

Let name the source data as Range, query it, unpivot all columns, split texts to lists, groups by columns with sum aggregation (or any other) and change in formula List.Sum on conversion to sequential list (see script), create final table based on result.

 

The script is

let
    Source = Excel.CurrentWorkbook(){[Name="Range"]}[Content],
    PromotHeaders = Table.PromoteHeaders(
        Source,
        [PromoteAllScalars=true]
    ),
    UnpivotColumns = Table.UnpivotOtherColumns(
        PromotHeaders,
        {},
        "Attribute", "Value"
    ),
    TextToList = Table.AddColumn(
        UnpivotColumns,
        "Custom",
        each Text.Split([Value],";")
    ),
    GroupRows = Table.Group(
        TextToList,
        {"Attribute"},
        {{"Count", each List.Distinct(List.Sort(List.Combine([Custom])))}}
    ),
    CreateTable = Table.FromColumns(
        GroupRows[Count],
        GroupRows[Attribute]
    )
in
    CreateTable