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
Anonymous
Not applicable

Transform Table

Hello,

I'm trying to do some transformations in a table.

My original table is like this:

 

YearGroupM_Checklist_01M_Checklist_02M_Checklist_03M_Checklist_04M_Checklist_05M_Checklist_06M_Checklist_07M_Checklist_08M_Checklist_09M_Checklist_10M_Checklist_11M_Checklist_12
2021M1090%50%50%90%100%90%100%90%90%90%90%10%
2021M110%50%50%0%100%0%100%0%0%0%0%10%
2022M120%50%50%0%100%0%100%0%0%0%0%10%
2022M130%50%50%0%100%0%100%0%0%0%0%10%

 

And I want to achive something like this:

 

DATEGROUPM_Checklist
01/01/2021M1090%
01/02/2021M1050%
01/03/2021M1050%
01/04/2021M1090%
01/05/2021M10100%
01/06/2021M1090%
01/07/2021M10100%
01/08/2021M1090%
01/09/2021M1090%
01/10/2021M1090%
01/11/2021M1090%
01/12/2021M1010%
01/01/2021M110%
01/02/2021M1150%
01/03/2021M1150%
01/04/2021M110%
01/05/2021M11100%
01/06/2021M110%
01/07/2021M11100%
01/08/2021M110%
01/09/2021M110%
01/10/2021M110%
01/11/2021M110%
01/12/2021M1110%
01/01/2021M120%
01/02/2021M1250%
01/03/2021M1250%
01/04/2021M120%
01/05/2021M12100%
01/06/2021M120%
01/07/2021M12100%
01/08/2021M120%
01/09/2021M120%
01/10/2021M120%
01/11/2021M120%
01/12/2021M1210%
01/01/2021M130%
01/02/2021M1350%
01/03/2021M1350%
01/04/2021M130%
01/05/2021M13100%
01/06/2021M130%
01/07/2021M13100%
01/08/2021M130%
01/09/2021M130%
01/10/2021M130%
01/11/2021M130%
01/12/2021M1310%

 

-> M_Chechpoint_1 equals to the first M_Checkpoint (January) in the defined year for each group; M_Chechpoint_2 equals to the second M_Checkpoint (february) in the defined year for each group;...


Anyway on how to do that?

Best regards

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

The basic step is to unpivot all except the first two columns. Then extract the month number and combine it with the Year to define the date.

 

Here's a full sample query you can paste into the Advanced Editor of a new blank query to examine the steps:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlTSUfI1NACSlgaqQNIUiYSIGBrg4mCShkAyVgfJYBCJYS6ySRhsNALJRCOwiUZUN9GYKibGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Group = _t, M_Checklist_01 = _t, M_Checklist_02 = _t, M_Checklist_03 = _t, M_Checklist_04 = _t, M_Checklist_05 = _t, M_Checklist_06 = _t, M_Checklist_07 = _t, M_Checklist_08 = _t, M_Checklist_09 = _t, M_Checklist_10 = _t, M_Checklist_11 = _t, M_Checklist_12 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Year", "Group"}, "Month", "M_Checklist"),
    #"Extracted Last Characters" = Table.TransformColumns(#"Unpivoted Other Columns", {{"Month", each Number.From(Text.End(_, 2)), Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Extracted Last Characters", "DATE", each #date([Year], [Month], 1), type date)
in
    #"Added Custom"

View solution in original post

1 REPLY 1
AlexisOlson
Super User
Super User

The basic step is to unpivot all except the first two columns. Then extract the month number and combine it with the Year to define the date.

 

Here's a full sample query you can paste into the Advanced Editor of a new blank query to examine the steps:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlTSUfI1NACSlgaqQNIUiYSIGBrg4mCShkAyVgfJYBCJYS6ySRhsNALJRCOwiUZUN9GYKibGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Group = _t, M_Checklist_01 = _t, M_Checklist_02 = _t, M_Checklist_03 = _t, M_Checklist_04 = _t, M_Checklist_05 = _t, M_Checklist_06 = _t, M_Checklist_07 = _t, M_Checklist_08 = _t, M_Checklist_09 = _t, M_Checklist_10 = _t, M_Checklist_11 = _t, M_Checklist_12 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Year", "Group"}, "Month", "M_Checklist"),
    #"Extracted Last Characters" = Table.TransformColumns(#"Unpivoted Other Columns", {{"Month", each Number.From(Text.End(_, 2)), Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Extracted Last Characters", "DATE", each #date([Year], [Month], 1), type date)
in
    #"Added Custom"

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.