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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.