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

MATRIX

Hi,

I'm trying to use a MATRIX for my dataset. My input data source has data in the following format:

 

DateH_StaffA_StaffT_StaffSt_Count
30/05/2013234
30/06/2037342
31/07/2024458
 

Myy Power BI Report should look like below:

 

AreaCount
Housekeeping Staff6
Administrative Staff14
T_Staff9
Student134

 

I'm using a text box to display Area, but I cant get count displayed in each rows.

Also, when I try to use a text box and MATRIX, there is white spacing between each and I cant align them properly. Is there a way I can remove the whitespace when using MATRIX and text box?

Any help is greatly appreciated.

 

Thanks,

AR

 

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@Anonymous - Try unpivoting your last 4 columns in Power Query Editor and this this should be very easy.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Anonymous
Not applicable

Hi @Anonymous 

Just like Greg_Deckler and mahoneypat  ‘s reply said Unpivot in Power Query Editor is a good way to achieve your goal.

The way to rename the column header is easy, you can right click the column headers in Power Query Editor or in Fields and choose Rename.

And you may try my way.

I build a table like yours to have a test.

1.png

Use raw data to build a matrix.

2.png

Then you select Show on rows in Values.

3.png

Result:

4.png

The result by this way may dont have column headers, but you can use the original data model to achieve your goal.

And you can build a text box and use group by right-click after selecting both two visuals.

5.png

You can download the pbix file from this link: MATRIX

 

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

 

Best Regards,

Rico Zhou

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous 

Just like Greg_Deckler and mahoneypat  ‘s reply said Unpivot in Power Query Editor is a good way to achieve your goal.

The way to rename the column header is easy, you can right click the column headers in Power Query Editor or in Fields and choose Rename.

And you may try my way.

I build a table like yours to have a test.

1.png

Use raw data to build a matrix.

2.png

Then you select Show on rows in Values.

3.png

Result:

4.png

The result by this way may dont have column headers, but you can use the original data model to achieve your goal.

And you can build a text box and use group by right-click after selecting both two visuals.

5.png

You can download the pbix file from this link: MATRIX

 

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

 

Best Regards,

Rico Zhou

 

Anonymous
Not applicable

Hi @Anonymous , That worked perfect.

 

In the output displayed, if I need to display one count as %, (say for example H_Count), how do I do that?

 

Thanks,

ara

amitchandak
Super User
Super User

@Anonymous , Unpivot in Power Query

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

 

Or in Display use Measure on Row

https://www.burningsuit.co.uk/blog/2019/04/7-secrets-of-the-matrix-visual/

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
Greg_Deckler
Community Champion
Community Champion

@Anonymous - Try unpivoting your last 4 columns in Power Query Editor and this this should be very easy.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks Greg. Where do I then rename rows? Do I rename using DAX if statements?

Here is some example M code to show you how to unpivot your data to set it up for simple analysis.  To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjbQNzDVNzJQ0lEyBGJjIDYC0SZKsToQWTOILEjGHEqbGEFkDfUNzCGyID0mUGxqoRQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, H_Staff = _t, A_Staff = _t, T_Staff = _t, St_Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type text}, {"H_Staff", Int64.Type}, {"A_Staff", Int64.Type}, {"T_Staff", Int64.Type}, {"St_Count", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Staff"}, {"Value", "Count"}})
in
    #"Renamed Columns"

 

Once you load that table, you just need to make a simple Table visual with the Staff column and the Sum of the Count column to get your desired result.

staff.png

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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