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
Gameboy334
Regular Visitor

Help with modifying data

I have a dataset coming in that has orders as a single line, with multiple columns showing the items and the details of the sales. I am trying to get the data transformed to an easier to read format. Below is an example of how the data is currently showing up. 

OrderIDDateTaxShippingTipTotalItem1Qty1ItemPrice1Item2Qty2ItemPrice2
123459/3/2310151095951224856112

 

Is there a way to change this to the below?

OrderIDDateTaxShippingTipTotalItemQtyItemPrice
123459/3/2310151095951224
123459/3/23    856112
1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

= #table(List.FirstN(Table.ColumnNames(KeepColumns),11) & {"Discount Amount","Discount Total","Item SubTotal","Item Total","Price","Product Name","Quantity","SKU"} , List.TransformMany(Table.ToRows(KeepColumns) , each List.Zip({{1},List.Split(List.Skip(_,11),8)}) , (x,y)=>List.FirstN(x,2)&List.ReplaceRange(y{1},0,0,if y{0}=null then List.Repeat({null},9) else List.Range(x,2,9))))

View solution in original post

4 REPLIES 4
wdx223_Daniel
Super User
Super User

= #table(List.FirstN(Table.ColumnNames(KeepColumns),11) & {"Discount Amount","Discount Total","Item SubTotal","Item Total","Price","Product Name","Quantity","SKU"} , List.TransformMany(Table.ToRows(KeepColumns) , each List.Zip({{1},List.Split(List.Skip(_,11),8)}) , (x,y)=>List.FirstN(x,2)&List.ReplaceRange(y{1},0,0,if y{0}=null then List.Repeat({null},9) else List.Range(x,2,9))))

wdx223_Daniel
Super User
Super User

NewStep== #table(List.FirstN(Table.ColumnNames(YourTableName),6)&{"Item","QTY","Price"},List.TransformMany(Table.ToRows(YourTableName),each List.Zip({{1},List.Split(List.Skip(_,6),3)}),(x,y)=>List.FirstN(x,2)&List.ReplaceRange(y{1},0,0,if y{0}=null then List.Repeat({null},4) else List.Range(x,2,4))))

I have entered the below as a new step but am getting the error below. Any thoughts on what I did wrong?

 

= KeepColumns(List.FirstN(Table.ColumnNames(KeepColumns),11) & {"Discount Amount","Discount Total","Item SubTotal","Item Total","Price","Product Name","Quantity","SKU"} , List.TransformMany(Table.ToRows(KeepColumns) , each List.Zip({{1},List.Split(List.Skip(_,11),8)}) , (x,y)=>List.FirstN(x,2)&List.ReplaceRange(y{1},0,0,if y{0}=null then List.Repeat({null},4) else List.Range(x,2,4))))

 

"Expression.Error: We cannot convert a value of type Table to type Function.
Details:
Value=[Table]
Type=[Type]

 

Thank you for the reply. Can you help me understand the components of the formula that you gave me? The full dataset is much more data than the example that I gave and I will need to customize the formula to fit my needs.

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 community update carousel

Fabric Community Update - June 2025

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