Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I’m having trouble to create a matrix table that contains columns calculated.
I have a data which appears as following :
Col1, Col2 and Col3 are calculated columns
Desired matrix is the following:
name | Total |
Col1 | 28 |
Col2 | 59 |
Col3 | 103 |
Please, any help?
Thank's in advance
Solved! Go to Solution.
Hi @SoufTC , I think I understand what you are going for!
In order to get the desired result , we would have to somehow unpivot the data table such that the columns become rows. Since you mentioned the columns are calculated columns, we would have to resort to DAX to implement that.
One idea is to create a new table from the original table such that the columns become row values (unpivoting) using DAX like so:
Data_Unpivoted =
UNION(
SELECTCOLUMNS(Data, "Name","Col1", "Total", Data[Col1]),
SELECTCOLUMNS(Data, "Name","Col2", "Total", Data[Col2]),
SELECTCOLUMNS(Data, "Name","Col3", "Total", Data[Col3])
)
Resulting table Data_Unpivoted looks like this:
Now, in the Matrix visual, we are able to drop the Data_Unpivoted[Name] column in the Row field and Data_Unpivoted[Total] column in the Value field. Thus getting this visual:
The DAX code we have above basically does 2 things:
1. Selects the specified column and lists out the values under it and tags the the column name under Name column of new table.
2. When we have listed all columns like this, we use UNION() to combine them together into a single table.
Hope this is meets your requirements. 😀
Hi, @SoufTC ;
You could add another table,the create a measure.
1.create a new table.
Table 2 = {"Column1","Column2","Column3"}
2.create a measure.
value = SWITCH(MAX('Table 2'[column]),"Column1",SUM('Table'[Column1]),"Column2",SUM('Table'[Column2]),"Column3",SUM('Table'[Column3]))
The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi SoufTC,
One of the simplest ways to do this would be to - toggle the "switch values to rows" option on.
Let me explain:
Step1: Add the columns to the values field
Step2: In the "Format Your Visual" tab, under "Values", under "Options", toggle the "Switch values to rows" option on.
This should give the result like below:
Hope this is what you were looking for.
@sathya_s thank you for your answer but it is not this technique that I wish to use because I would have to add other values in the matrix ! Also I would like to have the possibility to name the column
Hi @SoufTC , I think I understand what you are going for!
In order to get the desired result , we would have to somehow unpivot the data table such that the columns become rows. Since you mentioned the columns are calculated columns, we would have to resort to DAX to implement that.
One idea is to create a new table from the original table such that the columns become row values (unpivoting) using DAX like so:
Data_Unpivoted =
UNION(
SELECTCOLUMNS(Data, "Name","Col1", "Total", Data[Col1]),
SELECTCOLUMNS(Data, "Name","Col2", "Total", Data[Col2]),
SELECTCOLUMNS(Data, "Name","Col3", "Total", Data[Col3])
)
Resulting table Data_Unpivoted looks like this:
Now, in the Matrix visual, we are able to drop the Data_Unpivoted[Name] column in the Row field and Data_Unpivoted[Total] column in the Value field. Thus getting this visual:
The DAX code we have above basically does 2 things:
1. Selects the specified column and lists out the values under it and tags the the column name under Name column of new table.
2. When we have listed all columns like this, we use UNION() to combine them together into a single table.
Hope this is meets your requirements. 😀
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
24 | |
10 | |
10 | |
9 | |
6 |