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

showing data in matrix

Im going to show numbers per company per week in a table or matrix, but the way the data shows is wrong. I want the weeks to be horizontaly and the companies to be vertically. right now in my queries i have one column with weeks, and the numbers for the companies in each column. Is there a way i can put all the columns as rows instead. I dont want to use transpose, since then the weeks will be as columns. What im basically looking for is a way to have one column with the names of the company, one column for the week the data is from, and one column with the data. What i have now is a column with weeks, and seperate columns for each company.

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

if I got you right you need the pivot-function. Check out this solution

let
	Source = #table
	(
		{"Company","Week","Value"},
		{
			{"A","Week 1","1"},	{"A","Week 2","2"},	{"A","Week 3","3"},	{"A","Week 4","4"},	{"B","Week 1","5"},	{"B","Week 2","6"},	{"B","Week 3","7"},	{"B","Week 4","8"},	
			{"B","Week 5","9"},	{"C","Week 1","10"},	{"C","Week 2","11"},	{"C","Week 3","12"},	{"C","Week 4","13"}
		}
	),
    ChangedType = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}}),
    Pivot = Table.Pivot(ChangedType, List.Distinct(ChangedType[Week]), "Week", "Value", List.Sum)
in
    Pivot

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query or just select the week-column and select Transform -> Pivot column. In my solution i selected SUM for the aggregation. Change this if another calculation is needed (in case of multiple rows on Company/week-level.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

3 REPLIES 3
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

if I got you right you need the pivot-function. Check out this solution

let
	Source = #table
	(
		{"Company","Week","Value"},
		{
			{"A","Week 1","1"},	{"A","Week 2","2"},	{"A","Week 3","3"},	{"A","Week 4","4"},	{"B","Week 1","5"},	{"B","Week 2","6"},	{"B","Week 3","7"},	{"B","Week 4","8"},	
			{"B","Week 5","9"},	{"C","Week 1","10"},	{"C","Week 2","11"},	{"C","Week 3","12"},	{"C","Week 4","13"}
		}
	),
    ChangedType = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}}),
    Pivot = Table.Pivot(ChangedType, List.Distinct(ChangedType[Week]), "Week", "Value", List.Sum)
in
    Pivot

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query or just select the week-column and select Transform -> Pivot column. In my solution i selected SUM for the aggregation. Change this if another calculation is needed (in case of multiple rows on Company/week-level.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Anonymous
Not applicable

Hey @Jimmy801 

 

Thank you, I simply used the unpivit column function to fix it. But thanks for the help. 

Hello @Anonymous 

 

but this is exactly what I've written and showed you with the M-code

image.png

 

...

 

Jimmy

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 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.

Top Solution Authors