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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
ovonel
Post Prodigy
Post Prodigy

How to add a new column to the right of a matrix?

I have a matrix, with Weeks as columns, it works fine: 

ovonel_0-1682664848223.png

 

Now I want to add a new column... but of course, I can't add it... because it just takes the first value, how can I add at the end of the Weeks a new column with 'current project'? 

 

 

Current Project should appear to the right of it here:

ovonel_1-1682664981790.png

 

 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @ovonel 

According to your description, you want to "add a new column to the right of a matrix".

For your need  , you need to create a new table as a dimension table used for the column headers.

We can create it in Power Query Editor, you can create a blank query in Power Query Editor.

This is my test data:

vyueyunzhmsft_0-1682925052289.png

We can put this M code in the "Advanced Editor":

let
    Source = List.Sort( List.Distinct(Table[Week])) & {"Current project"},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

vyueyunzhmsft_1-1682925091275.png

We do not need to create any relationship between two tables.

Then we can create a measure like this:

Measure = var _column = MAX('Query1'[Column1])
var _v= CALCULATE( SUM('Table'[Staffing]) , TREATAS({IFERROR(VALUE(_column),BLANK())} , 'Table'[Week]))
return
IF(_column = "Current project" , "Your need data" , _v)

 

Then we can put the fields on the visual and we can get the result as follows:

vyueyunzhmsft_2-1682925150585.png

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @ovonel 

According to your description, you want to "add a new column to the right of a matrix".

For your need  , you need to create a new table as a dimension table used for the column headers.

We can create it in Power Query Editor, you can create a blank query in Power Query Editor.

This is my test data:

vyueyunzhmsft_0-1682925052289.png

We can put this M code in the "Advanced Editor":

let
    Source = List.Sort( List.Distinct(Table[Week])) & {"Current project"},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

vyueyunzhmsft_1-1682925091275.png

We do not need to create any relationship between two tables.

Then we can create a measure like this:

Measure = var _column = MAX('Query1'[Column1])
var _v= CALCULATE( SUM('Table'[Staffing]) , TREATAS({IFERROR(VALUE(_column),BLANK())} , 'Table'[Week]))
return
IF(_column = "Current project" , "Your need data" , _v)

 

Then we can put the fields on the visual and we can get the result as follows:

vyueyunzhmsft_2-1682925150585.png

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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