Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
akkitek
Helper III
Helper III

Adding columns to the right of the total column in a matrix

Hi Everyone,
I'm trying to add a couple of columns to the right of the Total column in a matrix. I need to make my matrix look exactly like the image below.

akkitek_0-1667470918392.png

 

I have created a matrix by adding the weeks field in the columns section (image below) . I need to add contract rate and contract revenue fields to the right of the total column. 

akkitek_1-1667471120222.png

 

I also tried creating this in a table visual instead of a matrix and pivioted the weeks field to get individual columns for every week but manually totalling the columns becomes hard and once the dashabord is published the new weeks data wouldn't get added into the visual. Any idea how I can achieve this? Please find attached my sample file below. Thanks!


https://drive.google.com/file/d/1xKXW5377Xan4Tkn1D7TwjHBeQkNkXcpI/view?usp=sharing

 

1 ACCEPTED SOLUTION

"each date but when new weeks' data comes in, we'd have to hide them manually every week right?"

Yes, unfortunately

Here is one way of creating the custom matrix table for the layout:

 

Hybrid Matrix =
VAR _NumWeeks =
    DISTINCTCOUNT ( log_file[Week] ) * 10
VAR _Weeks =
    ADDCOLUMNS (
        DISTINCT ( log_file[Week] ),
        "Order", RANKX ( ALL ( log_file[Week] ), log_file[Week],, ASC, DENSE )
    )
VAR _Metrics = {
    ( "Total", _NumWeeks ),
    ( "Rate", _NumWeeks + 1 ),
    ( "Amount", _NumWeeks + 2 )
}
RETURN
    ADDCOLUMNS (
        UNION ( _Weeks, _Metrics ),
        "Week B", IF ( [Order] >= _NumWeeks, BLANK (), log_file[Week] )
    )

 

matrix table.jpg

 I have added an extra column (Week B) to have the week dates formatted as actual dates, which you will need for the calcualtions.

result.jpg

Sorry, I couldn't move forward with the actual measure for the matrix since I don't know what you wish to calculate for each field.

 

Sample PBIX file attached





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

3 REPLIES 3
PaulDBrown
Community Champion
Community Champion

You can either include the measures and hide the unwanted columns by each date (turn off Word Wrap in the formatting pane for columns and then drag the right edge of the column to the left),

or you can build a "custom" matrix. See if this helps:

https://community.powerbi.com/t5/Community-Blog/Creating-a-custom-or-hybrid-matrix-in-PowerBI/ba-p/1... 

 

In your case, to get the columns to the right, you must assign a really high index number (higher than the possible number of dates in the model).

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hey @PaulDBrown ,
I like the idea of hiding unwanted columns by each date but when new weeks' data comes in, we'd have to hide them manually every week right? 
I wouldn't mind the custom matrix approach if it gets us to the desired output but I'm having some trouble creating the custom matrix, would it be possible for you to show me how its done in the attached sample file? 
Thanks for all the support:)

"each date but when new weeks' data comes in, we'd have to hide them manually every week right?"

Yes, unfortunately

Here is one way of creating the custom matrix table for the layout:

 

Hybrid Matrix =
VAR _NumWeeks =
    DISTINCTCOUNT ( log_file[Week] ) * 10
VAR _Weeks =
    ADDCOLUMNS (
        DISTINCT ( log_file[Week] ),
        "Order", RANKX ( ALL ( log_file[Week] ), log_file[Week],, ASC, DENSE )
    )
VAR _Metrics = {
    ( "Total", _NumWeeks ),
    ( "Rate", _NumWeeks + 1 ),
    ( "Amount", _NumWeeks + 2 )
}
RETURN
    ADDCOLUMNS (
        UNION ( _Weeks, _Metrics ),
        "Week B", IF ( [Order] >= _NumWeeks, BLANK (), log_file[Week] )
    )

 

matrix table.jpg

 I have added an extra column (Week B) to have the week dates formatted as actual dates, which you will need for the calcualtions.

result.jpg

Sorry, I couldn't move forward with the actual measure for the matrix since I don't know what you wish to calculate for each field.

 

Sample PBIX file attached





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.