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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
hath117
New Member

Split variables and associated values into separate columns

Hi!
I have this particular table:

VariablesValues
new person4
new person9
new person8
new person2
old person5
old person1
old person7
old person3

 

Now I want to convert the table in such a way that the final output should return this:

VariableValue_1VariableValue_2
new person4old person5
new person9old person1
new person8old person7
new person2old person3

 

So basically I want to split the variables and their associated values from one column to separate columns. Any tips / workarounds ?

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

=Table.FromColumns(List.Combine(Table.Group(PreviousStepName,"Variable",{"n",Table.ToColumns})[n]),List.TransformMany({0..List.Count(List.Distinct(PreviousStepName[Variable]))-1},each Table.ColumnNames(PreviousStepName),(x,y)=>if x=0 then y else y&"_"&Text.From(x)))

View solution in original post

1 REPLY 1
wdx223_Daniel
Super User
Super User

=Table.FromColumns(List.Combine(Table.Group(PreviousStepName,"Variable",{"n",Table.ToColumns})[n]),List.TransformMany({0..List.Count(List.Distinct(PreviousStepName[Variable]))-1},each Table.ColumnNames(PreviousStepName),(x,y)=>if x=0 then y else y&"_"&Text.From(x)))

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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