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

Matrix table

I would like to transform my table as follow:

Untitled.png

Can anyone her helps me to solve this problem? Thank you in advanced! 

4 REPLIES 4
PaulDBrown
Community Champion
Community Champion

Do you actually need this as a physical table in your model? If you need to see it as a visual, all you need is to create a measure using COUNT for the discount field and create a matrix with the customers as rows, the discount field as columns and the measure as values. So...

Count Discount = 
COUNT(fTable[Discount])

matrix.jpg

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@Anonymous , You need to use pivot

 

https://radacad.com/pivot-and-unpivot-with-power-bi

 

example code

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUfJJLUvNUTBUitVB5huB+Ulo8knI8rEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t, Discount = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Discount", type text}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Discount", "Discount - Copy"),
    #"Pivoted Column" = Table.Pivot(#"Duplicated Column", List.Distinct(#"Duplicated Column"[Discount]), "Discount", "Discount - Copy", List.Count)
in
    #"Pivoted Column"
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hei,

 

The table in the right  is showing the count number of Discout (level) each Customer has received.

 

Hi @Anonymous ,

 

1. Duplicate "discount"column

Vlianlmsft_0-1649922768121.png

2. Pivot the "discount" column:

Vlianlmsft_1-1649922814535.png

 


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

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.