Forum Discussion

chunyong's avatar
chunyong
New Member
6 years ago
Solved

Getting count of values from a column

Hi everyone,   I have a dataframe like this Index Col A Col B Col C u1 data string1,string2,string3 etc d1 u2 data string1, string15 d1 u3 data string4,string5 d1 u4 da...
  • mussaenda's avatar
    6 years ago

    hi chunyong 

     

    Based on your sample data, it is possible.

    Try this:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKjVU0lFKSSxJBFLFJUWZeemGOhDaCEobgxQYKsXqABUbYSpWgDJMkZQZoyszgZqFrMgEXZE5kqQphkXIzjDD5WZTHTTXxAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Index = _t, #"Col A" = _t, #"Col B" = _t, #"Col C" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index", type text}, {"Col A", type text}, {"Col B", type text}, {"Col C", type text}}),
        #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Col B", "Col B - Copy"),
        #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Duplicated Column", {{"Col B", Splitter.SplitTextByDelimiter(",", QuoteStyle.None), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Col B"),
        #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Col B", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type1", {"Col B"}, {{"Data String Count", each Table.RowCount(_), type number}, {"Details", each _, type table [Index=text, Col A=text, Col B=text, Col C=text, #"Col B - Copy"=text]}}),
        #"Expanded Details" = Table.ExpandTableColumn(#"Grouped Rows", "Details", {"Index", "Col A", "Col C", "Col B - Copy"}, {"Details.Index", "Details.Col A", "Details.Col C", "Details.Col B - Copy"})
    in
        #"Expanded Details"