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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Legend_11
Resolver I
Resolver I

Transform Table

I want to transfrom the data as mentioned below, is there any way I could achieve this either in powerquery or either in front end

WeekMaterialSALESPROFITDiscount WeekMaterialSALESPROFITDiscount
1A324 1A11  
1B415 2A11  
1C336 3A11  
1D346 4A 22 
1E657 5A 22 
1F767 6A  33
      7A  33
      8A  33
      9A  33
      1B11  
      2B11  
      3B11  
      4B11  
      5B 22 
      6B  33
      7B  33
      8B  33
      9B  33
      10B  33
3 REPLIES 3
BA_Pete
Super User
Super User

Hi @Legend_11 ,

 

Can you explain the logic of how to get from table1 to table2 please?

I can't see any type of pattern between the data in each table.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




for example I will take first row, 

Material A has 3 sales, I want to split the rows to 3 and also add+1 to the week  , nexxt profit has to come two rows (numbers 11,22,33 are just random int i am using) + continue the addition of week 

 

 

Ok. You can create and expand a list that runs from 1 to the sum of [SALES], [PROFIT], and [Discount], like this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIGYiMgNlGK1YlWcgKzdJQMgdgULOIMVQPCZmARFyjPBC7iCmaBdOgomYNF3MAsiChQJBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Material = _t, SALES = _t, PROFIT = _t, Discount = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"Material", type text}, {"SALES", Int64.Type}, {"PROFIT", Int64.Type}, {"Discount", Int64.Type}}),

    addWeek = Table.AddColumn(chgTypes, "Week", each {1..List.Sum({[SALES],[PROFIT],[Discount]})}),
    expandWeek = Table.ExpandListColumn(addWeek, "Week")

in
    expandWeek

 

Output:

BA_Pete_0-1693466633356.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.