Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Separating text and lists that are together in one column into two columns

Good morning everyone,

 

I am currently working in Power Query where I have retrieved a table from Liongard. This table is supposed to show the groups list including members of Office 365. I had to expand the row twice to get the list in its current form (see image).

lisanneAsked_0-1717570302003.png

 

As you can see, there are both text and new lists mixed together. The text you see is the name of the group. The list below contains all the users. What I would like to do is separate this, so I can expand the list of names as well. Right now, the data is not useful to me in this format.

What I would like to achieve is to have two columns: one with the name of the group and the row next to it with the user.

 

 

Example:
Group              NameMember 
X                      *name member* 
X                      *name member* 
X                      *name member* 
Y                      *name member* 
Y                      *name member* 

 

I hope someone can help me with this!

Thanks in advance for the assistance!

 

Kind regard,

Lisanne

1 ACCEPTED SOLUTION

@Anonymous I just imitated your table with #table() statement because you did not provide data in usable format. Suppose your table has single column named Group. Then:

let
    Source = your_table,
    group = Table.Group(
        Source, "Group", 
        {"x", (x) => x[Group]{1}}, 
        GroupKind.Local, 
        (s, c) => Number.From(Value.Is(c, type text))
    ),
    xp = Table.ExpandListColumn(group, "x")
in
    xp

 

View solution in original post

11 REPLIES 11
AlienSx
Super User
Super User

let
    Source = #table(
        {"Group"}, 
        {{"All Company"}, {{"Joseph", "Stalin"}}, 
        {"Alle gebruikers"}, {{"Lisanne", "Asked"}}}
    ),
    group = Table.Group(
        Source, "Group", 
        {"x", (x) => x[Group]{1}}, 
        GroupKind.Local, 
        (s, c) => Number.From(Value.Is(c, type text))
    ),
    xp = Table.ExpandListColumn(group, "x")
in
    xp
Anonymous
Not applicable

Hi @AlienSx ,

 

Thanks for responding. I have more groups than the ones mentioned above; those were just examples.

Do you know the best way to handle this?

 

Kind regards,

Lisanne

@Anonymous replace Source table with a reference to your table and see what happens. 

I'm starting out in power query and I wanted to understand what it means: {"x", (x) => x[Group]{1}}, and also: (s, c) => Number.From(Value.Is(c , type text)), thank you in advance for your explanation.

@omjcontabil read Table.Group documentation. {"x", (x) => ...} is 

aggregatedColumns as list

Grouping can be global or local. We are dealing with GroupKind.Local in this case. (s, c) => function must return 1 or 0 - that's Table.Group's requirement. When function returns 1 then new group is started. 

Anonymous
Not applicable

Hi @AlienSx ,

Thanks again for responding. When I load the table, I only get lists. I expand these, and then I end up with the situation described above. If I add your code in the advanced editor, I lose that as well.

I don't understand the best way to do this. How should I proceed?

 

Kind regards

Lisanne

@Anonymous my code works with table (of single column like in your sample) with the following structure: text - list - text - list - text -.... Make sure that input data (the table you are loading) has the same structure and then apply my code.

Anonymous
Not applicable

Hello @AlienSx ,

Thank you for your response!

 

I don't understand this part of the query:
{{"All Company"}, {{"Joseph", "Stalin"}},

{"All Users"}, {{"Lisanne", "Asked"}}}

Do I have to do this for all the groups? So, do I need to specify each group and its members? I have more than 100 groups with users so this wouldn't be feasible for me.. 

 

I look forward to hearing from you!

 

Kind regards,
Lisanne

@Anonymous I just imitated your table with #table() statement because you did not provide data in usable format. Suppose your table has single column named Group. Then:

let
    Source = your_table,
    group = Table.Group(
        Source, "Group", 
        {"x", (x) => x[Group]{1}}, 
        GroupKind.Local, 
        (s, c) => Number.From(Value.Is(c, type text))
    ),
    xp = Table.ExpandListColumn(group, "x")
in
    xp

 

Anonymous
Not applicable

Hi @AlienSx ,

Sorry for not being clear. There are multiple columns in that table. How can I best approach this?

I look forward to hearing from you!

Best regards,
Lisanne

remove other columns

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors