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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Dbar84
Frequent Visitor

Help: Reordering the Values of each Row in Numerical Order

Raw Data SampleRaw Data SampleDesired ResultDesired Result

 

I have a company hierarchy levels that are in one column but they are not in numerical orders(image 1).

 

My end goal is to have the levels in numerical order in one column(image 2).

 

Could someone help me accomplish this in Power Query? I've included screenshots above showing what I'm trying to accomplish. 

 

So far I've tried the following steps:

  1. split the column by the comma into 7 different columns

  2. extracting the second character from each of the 7 split column to determine the level number.

  3. Then tried to merge all 7 columns back into one column using conditional columns based on the level number extracted in the previous step. In this step I get null in all the rows once I combined the fifth column with the previous 4 columns.

I feel like I'm over complicating this and maybe there is an easier way to accomplish with M code.

 

If anyone could help, I'd highly appreciated.

1 ACCEPTED SOLUTION
spinfuzer
Super User
Super User

Right click on the column --> Transform --> click on anything like lower case then edit the formula

 

= Table.TransformColumns(#"Changed Type",{{"Column1", each Text.Combine(List.Sort(Text.Split(_, ", ")), ", "), type text}})

spinfuzer_0-1706060756810.png

 

 

 

View solution in original post

2 REPLIES 2
spinfuzer
Super User
Super User

Right click on the column --> Transform --> click on anything like lower case then edit the formula

 

= Table.TransformColumns(#"Changed Type",{{"Column1", each Text.Combine(List.Sort(Text.Split(_, ", ")), ", "), type text}})

spinfuzer_0-1706060756810.png

 

 

 

A big THANK YOU! This did the trick. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors