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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Ka4ra
New Member

How to change data (pivot? Group?)

I want to change the data format.

 

Below is sample data. Data has a same ID, Value but Col1 to Col7 some have data and some do not.

I'm doing data transformation in Power BI, but I don't know what to do. 

 

DateIDVALUECol1Col2Col3Col4Col5Col6Col7
23-01-01 2:40 PMAAAAA320null225nullnullnullnull
23-01-01 2:40 PMAAAAA32015nullnullnull20nullnull
23-01-01 2:40 PMAAAAA320nullnullnull52nullnullnull
23-01-02 12:10 PMAVSV2491021null26nullnullnull
23-01-02 12:10 PMAVSV249nullnullnullnullnullnullnull
23-01-02 12:10 PMAVSV249nullnull0.1nullnullnullnull

 

 

I want to change the format data look like below.

I would like to put the data of each column matching the ID into one ID row for each column.

DateIDVALUECol1Col2Col3Col4Col5Col6Col7
23-01-01 2:40 PMAAAAA320152255220nullnull
23-01-02 12:10 PMAVSV24910210.126nullnullnull

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Ka4ra ,

 

Here are the steps you can follow:

1. Create calculated table.

Table2 =
SUMMARIZE(
    'Table',[Date],[ID],[VALUE],
    "Co1",MAX('Table'[Col1]),
    "Co2",MAX('Table'[Col2]),
    "Co3",MAX('Table'[Col3]),
    "Co4",MAX('Table'[Col4]),
    "Co5",MAX('Table'[Col5]),
    "Co6",MAX('Table'[Col6]),
    "Co7",MAX('Table'[Col7]))

2. Result:

vyangliumsft_0-1705642921606.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Ka4ra ,

 

Here are the steps you can follow:

1. Create calculated table.

Table2 =
SUMMARIZE(
    'Table',[Date],[ID],[VALUE],
    "Co1",MAX('Table'[Col1]),
    "Co2",MAX('Table'[Col2]),
    "Co3",MAX('Table'[Col3]),
    "Co4",MAX('Table'[Col4]),
    "Co5",MAX('Table'[Col5]),
    "Co6",MAX('Table'[Col6]),
    "Co7",MAX('Table'[Col7]))

2. Result:

vyangliumsft_0-1705642921606.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amustafa
Solution Sage
Solution Sage

In Power Query, all you need to do is to Group By Date, ID and Value and do a SUM on rest of the columns. Here's a sample M Code. Adjust the source and let it run.

 

let
Source = Excel.Workbook(File.Contents("C:\tmp\Power BI Samples\Grouping Data\Group Data Sample.xlsx"), null, true),
Table1_Table = Source{[Item="Table1",Kind="Table"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Table1_Table,{{"Date", type text}, {"ID", type text}, {"VALUE", Int64.Type}, {"Col1", Int64.Type}, {"Col2", Int64.Type}, {"Col3", type number}, {"Col4", Int64.Type}, {"Col5", Int64.Type}, {"Col6", type any}, {"Col7", type any}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Date", "ID", "VALUE"}, {{"Col1", each List.Sum([Col1]), type nullable number}, {"Col2", each List.Sum([Col2]), type nullable number}, {"Col3", each List.Sum([Col3]), type nullable number}, {"Col4", each List.Sum([Col4]), type nullable number}, {"Col5", each List.Sum([Col5]), type nullable number}, {"Col6", each List.Sum([Col6]), type any}, {"Col7", each List.Sum([Col7]), type any}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Grouped Rows",{{"Col1", type number}, {"Col2", type number}, {"Col3", type number}, {"Col4", type number}, {"Col5", type number}, {"Col6", type number}, {"Col7", type number}})
in
#"Changed Type1"

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors