Forum Discussion
Matrix - change level of column headers
I have some data that is structured in a way shown in Fig. 1. My goal is to create a pivot table (using Matrix) that looks like one I created in Excel (see Fig. 2.). However, in Power BI I get a matrix in which years have the upper level, and my variables have a lower level (see Fig. 3). How do I change the level of years and my variables?
Fig. 1:
Fig. 2:
Fig. 3:
Hi gorsheep ,
You need unpivot the underlying table in power query firstly.
And create measure as the following code:
Measure = IF ( SELECTEDVALUE ( 'Table'[Attribute] ) = "Margin", FORMAT ( SUM ( 'Table'[Value] ), "#%" ), FORMAT ( SUM ( 'Table'[Value] ), "#" ) )Visualization pane:
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- v-chenwuz-msft
Community Support
Hi gorsheep ,
You need unpivot the underlying table in power query firstly.
And create measure as the following code:
Measure = IF ( SELECTEDVALUE ( 'Table'[Attribute] ) = "Margin", FORMAT ( SUM ( 'Table'[Value] ), "#%" ), FORMAT ( SUM ( 'Table'[Value] ), "#" ) )Visualization pane:
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- gorsheepRegular Visitor
Hi! Below is a screenshot of the current setup, which yields a table shown in Fig. 3 of the original post. If I move "Year" to the "Values" pane, it just removes the second level of the header.