Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
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.
Solved! Go to Solution.
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
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
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
...
Jimmy
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.