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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
rmzkk
New Member

Select Certain Row to Transform Into Column

Greetings,

 

I have a raw data like this, it shows a unit type, unit id, and its performance (PA and UA)  per-date

rmzkk_0-1771165164997.png

notice in row 3 there is data containing date, and below it (row 143) there is also a date

 

rmzkk_1-1771165440232.png

i want to transform it to something like this

rmzkk_2-1771165904240.png

 

tried transpose it but it doesn't sync with other data, how can i do it?

Any suggestion will be appriciated, thanks!

1 REPLY 1
AlienSx
Super User
Super User

let
    fx = (tbl) => ((dates) => List.TransformMany(
        Table.ToList(Table.RemoveFirstN(tbl, 1), (x) => List.RemoveFirstN(x, 2)),
        (x) => List.Zip({dates, List.Split(List.RemoveFirstN(x, 2), 2)}),
        (x, y) => {y{0}} & List.FirstN(x, 2) & y{1}
    ))(List.RemoveNulls(List.RemoveFirstN(Record.ToList(tbl{0}), 4))),
    Source = Excel.Workbook(File.Contents("path_to_your_file\data_file.xlsx"), null, true)[Data]{0},
    sel = Table.SelectRows(Source, (x) => x[Column3] <> null),
    group = Table.Group(sel, "Column3", {"x", fx}, GroupKind.Local, (s, c) => Number.From(c = "Unit")),
    z = Table.FromList(List.Combine(group[x]), (x) => x, {"Date", "Unit", "Model", "PA", "UA"})
in
    z

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.