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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Mat87
Frequent Visitor

Table Transforming

So I have a table that looks like this:

 

e1.png

 

I want to transformat it into something that looks like this:

 

e2.png

Any idea what would be the way to do this in DAX?

1 ACCEPTED SOLUTION
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @Mat87,

If you allow, you can edit the table in Query Edit.

1. Please select Year column->Pivot Column.

1.PNG

2. After click Pivot Column->value field.

2.PNG

3. Then alick close&Apply, you will get theexpected result.

3.png

In addition, this is the Power Query statement.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIyMDQGUcamJkZKsTpwQRMQZWJkAhZLAosZWILFDI2QxSyAlKmpEUgwFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Year = _t, value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Year", Int64.Type}, {"value", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Year", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Year", type text}}, "en-US")[Year]), "Year", "value", List.Sum)
in
    #"Pivoted Column"


Please feel free to ask if you have any issue.

Best Regards,
Angelia

View solution in original post

3 REPLIES 3
Mat87
Frequent Visitor

Thanks guys. 

v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @Mat87,

If you allow, you can edit the table in Query Edit.

1. Please select Year column->Pivot Column.

1.PNG

2. After click Pivot Column->value field.

2.PNG

3. Then alick close&Apply, you will get theexpected result.

3.png

In addition, this is the Power Query statement.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIyMDQGUcamJkZKsTpwQRMQZWJkAhZLAosZWILFDI2QxSyAlKmpEUgwFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Year = _t, value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Year", Int64.Type}, {"value", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Year", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Year", type text}}, "en-US")[Year]), "Year", "value", List.Sum)
in
    #"Pivoted Column"


Please feel free to ask if you have any issue.

Best Regards,
Angelia

Anonymous
Not applicable

@Mat87

I assume you ask how display the table in the desired format and not to change the table itself.

You can use the Matrix.

 

grafik.png

 

grafik.png

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

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.