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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Chateauunoirr
Advocate I
Advocate I

Create a matrix from a data table by type, types that do not exist today

Hello, I have the Project object from Salesforce, which has on the same line for each project, initial and completed amounts for types X and Y.

 

I want to display in matrix format the progress of the project, the amounts excepted and completed.

 

As seen below a current representation, of the data that I have today is what I want to do as a display, what would be the best method to choose?

 

Power BI forum .png

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @Chateauunoirr 
At the first step (s} you need to transform your table to unpivoted format.

Ritaf1983_0-1734091912152.png

The m code for this :
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQooys9KTS5RcASyDQ0MDCAUkDSCcIyBZKxOtJIRklonINsUIm0C0wGnlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, #"Project Name" = _t, #"Expected Amount X" = _t, #"Realized Amount X" = _t, #"Expected Amount Y" = _t, #"Realized Amount Y" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Id", Int64.Type}, {"Project Name", type text}, {"Expected Amount X", Int64.Type}, {"Realized Amount X", Int64.Type}, {"Expected Amount Y", Int64.Type}, {"Realized Amount Y", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Id", "Project Name"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Attribute.2", "sub project"}, {"Attribute.1", "status"}}),
#"Split Column by Delimiter1" = Table.SplitColumn(#"Renamed Columns", "status", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"status.1", "status.2"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"status.1", type text}, {"status.2", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type2",{"status.2"}),
#"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"status.1", "status"}})
in
#"Renamed Columns1"

Or you can apply the needed step from UX of query editor , I attached the pbix to the solution so you can follow:

Ritaf1983_1-1734092012842.png

After closing and applying you can create 3 DAX measures :

Ritaf1983_2-1734092102384.png

expected =
var expected_= FILTER('Table','Table'[status]="expected")
RETURN
SUMX(expected_,'Table'[Value])
 
Ritaf1983_3-1734092135247.png
Realized =
var realized_= FILTER('Table','Table'[status]="realized")
RETURN
SUMX(realized_,'Table'[Value])
Ritaf1983_4-1734092172780.png

Now just create a wanted matrix:

Ritaf1983_5-1734092204569.png

The pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

5 REPLIES 5
danextian
Super User
Super User

Is that really the current representation of your data? I am asking because a lot of users  have posted oversimplified data, were given a working solution based on the sample data only to come back later saying the data was more complex than the users made it appear.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian Hi, of course this is a simplified form but there are just more than two types "X,Y", so the method I would apply for both will apply for my model with 4 types "X,Y,Z,T"

Chateauunoirr
Advocate I
Advocate I

Hello, thank you very much for your help the only problem is that my projects table is much more complex and is linked to a lot of tables I can not make changes directly on it. Do you think that doing it via a copied project table or doing it via DAX is possible?

Hi @Chateauunoirr 


I doubt that DAX is intended for table transformations; this is part of ETL processes that should be handled either at the data source before importing into Power BI or in Power Query (PQ).

There is a video about performing an Unpivot using DAX, but again, I’m not sure where this approach can lead from there.

https://www.youtube.com/watch?v=9Xv8COs59tc

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

Hi @Chateauunoirr 
At the first step (s} you need to transform your table to unpivoted format.

Ritaf1983_0-1734091912152.png

The m code for this :
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQooys9KTS5RcASyDQ0MDCAUkDSCcIyBZKxOtJIRklonINsUIm0C0wGnlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Id = _t, #"Project Name" = _t, #"Expected Amount X" = _t, #"Realized Amount X" = _t, #"Expected Amount Y" = _t, #"Realized Amount Y" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Id", Int64.Type}, {"Project Name", type text}, {"Expected Amount X", Int64.Type}, {"Realized Amount X", Int64.Type}, {"Expected Amount Y", Int64.Type}, {"Realized Amount Y", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Id", "Project Name"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Attribute.2", "sub project"}, {"Attribute.1", "status"}}),
#"Split Column by Delimiter1" = Table.SplitColumn(#"Renamed Columns", "status", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"status.1", "status.2"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"status.1", type text}, {"status.2", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type2",{"status.2"}),
#"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"status.1", "status"}})
in
#"Renamed Columns1"

Or you can apply the needed step from UX of query editor , I attached the pbix to the solution so you can follow:

Ritaf1983_1-1734092012842.png

After closing and applying you can create 3 DAX measures :

Ritaf1983_2-1734092102384.png

expected =
var expected_= FILTER('Table','Table'[status]="expected")
RETURN
SUMX(expected_,'Table'[Value])
 
Ritaf1983_3-1734092135247.png
Realized =
var realized_= FILTER('Table','Table'[status]="realized")
RETURN
SUMX(realized_,'Table'[Value])
Ritaf1983_4-1734092172780.png

Now just create a wanted matrix:

Ritaf1983_5-1734092204569.png

The pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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