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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Top Kudoed Authors