Forum Discussion

ABR002's avatar
ABR002
Helper I
1 year ago
Solved

Help with Pivoting or Transposing columns with unaggregated multiple values

I have a liist of networks and a list of groups that are found on thoe networks:

NetworkGroup_Name
10.100.100.10HR
10.100.100.11HR
10.100.100.11IT
10.100.100.11

Logistics

10.100.100.12HR
10.100.100.12Logistics
10.100.100.13IT


If a networks has multiple groups, I'd like to get them on the same line and cell:

NetworkGroup_Names
10.100.100.10HR
10.100.100.11HR, IT, Logistics
10.100.100.12HR, Logistics
10.100.100.13IT

 

I tried to Pivot with unaggregated values, so I could get everything on one line and do a custom column with all the column values, but I get an error when I try to pivot, it won't do more than one row. In hindsight this might not have been a good solution anyway (though I might have had a way to plow through it) as the data source will be updated from time to time and the number of maximum groups will fluctuate. Current record is over 30.

  • // Table
    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTQMzSAYSUdJY8gpVgdVGFD3MKeIViFffLTM4tLMpOLMWSNsJtlhFeTMdSmWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Network = _t, Group_Name = _t]),
        #"Grouped Rows" = Table.Group(Source, {"Network"}, {{"Groups", each Text.Combine(_[Group_Name],",")}})
    in
        #"Grouped Rows"
  • Hi ABR002,
    Thank you for reaching out to the Microsoft Fabric Forum Community.

    I’ve reproduced your scenario using my sample data and I was able to achieve the expected output. Here's a summary of the steps I took:

    • Grouped the data by Network and collected the Group_Name values into a list under the AllGroups column.
    • Created a custom column to concatenate the Group_Name values using the following M code:
    Text.Combine(List.Transform([AllGroups][Group_Name], each Text.From(_)), ", ")

    For your reference, I’ve attached a screenshot of the output and the .pbix file with the solution.


    Thank you, lbendlin for sharing your valuable insights.

    If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
    Thank you.

2 Replies

  • // Table
    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTQMzSAYSUdJY8gpVgdVGFD3MKeIViFffLTM4tLMpOLMWSNsJtlhFeTMdSmWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Network = _t, Group_Name = _t]),
        #"Grouped Rows" = Table.Group(Source, {"Network"}, {{"Groups", each Text.Combine(_[Group_Name],",")}})
    in
        #"Grouped Rows"
  • v-ssriganesh's avatar
    v-ssriganesh
    Community Support

    Hi ABR002,
    Thank you for reaching out to the Microsoft Fabric Forum Community.

    I’ve reproduced your scenario using my sample data and I was able to achieve the expected output. Here's a summary of the steps I took:

    • Grouped the data by Network and collected the Group_Name values into a list under the AllGroups column.
    • Created a custom column to concatenate the Group_Name values using the following M code:
    Text.Combine(List.Transform([AllGroups][Group_Name], each Text.From(_)), ", ")

    For your reference, I’ve attached a screenshot of the output and the .pbix file with the solution.


    Thank you, lbendlin for sharing your valuable insights.

    If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
    Thank you.