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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
FredQ
Frequent Visitor

Cube.AddAndExpandDimensionColumn and New Column Name

I have tried everything I can think of and I cannot rename a column in the same line as Cube.AddAndExpandDimensionColumn.  

 

Here is the normal line without a rename:

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business.Business Level 01"}},

 

I want to rename the column, as Microsoft tells me I can.  https://learn.microsoft.com/en-us/powerquery-m/cube-addandexpanddimensioncolumn#syntax

 

 

I try this:

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business.Business Level 01"}, "Business"},

 

and get this error:

 

Expression.Error: 5 arguments were passed to a function which expects between 3 and 4.
Details:
Pattern=
Arguments=[List]

 

How does it get to 5 arguments?

 

I try this:

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business.Business Level 01"}, {"Business"}},

 

and get this error:

 

Expression.Error: 5 arguments were passed to a function which expects between 3 and 4.
Details:
Pattern=
Arguments=[List]

 

I try this:

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business.Business Level 01", "Business"}},

 

and get this error:

 

Expression.Error: We expected newColumnNames to have the same number of items as attributeNames.
Details:
[List]

 

There is only 1 column to return.  I rename 1 column.  How is that not the same number?

 

What am I doing wrong?  What is the correct syntax to accomplish this?

 

1 ACCEPTED SOLUTION
FredQ
Frequent Visitor

I figured it out!

 

I can simply rename it directly in the line by changing the last parameter:

 

Original created by the system:

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business.Business Level 01"}},
{Table.AddColumn, "Business Code", each Cube.AttributeMemberProperty([Business.Business Level 01], "[20PROFIT_CTR__ZBBUSINES]")},

 

Original I tried this: (change in bold red)

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business"}},
{Table.AddColumn, "Business Code", each Cube.AttributeMemberProperty([Business.Business Level 01], "[20PROFIT_CTR__ZBBUSINES]")},

 

And I got an error.  The reason is not because I cannot do it there, it was becasue I referred to the item in the next row of code and did not change it there.  This is what I needed:

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business"}},
{Table.AddColumn, "Business Code", each Cube.AttributeMemberProperty([Business], "[20PROFIT_CTR__ZBBUSINES]")},

View solution in original post

4 REPLIES 4
FredQ
Frequent Visitor

I figured it out!

 

I can simply rename it directly in the line by changing the last parameter:

 

Original created by the system:

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business.Business Level 01"}},
{Table.AddColumn, "Business Code", each Cube.AttributeMemberProperty([Business.Business Level 01], "[20PROFIT_CTR__ZBBUSINES]")},

 

Original I tried this: (change in bold red)

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business"}},
{Table.AddColumn, "Business Code", each Cube.AttributeMemberProperty([Business.Business Level 01], "[20PROFIT_CTR__ZBBUSINES]")},

 

And I got an error.  The reason is not because I cannot do it there, it was becasue I referred to the item in the next row of code and did not change it there.  This is what I needed:

 

{Cube.AddAndExpandDimensionColumn, "[0PROFIT_CTR__ZBBUSINES]", {"[0PROFIT_CTR__ZBBUSINES].[LEVEL01]"}, {"Business"}},
{Table.AddColumn, "Business Code", each Cube.AttributeMemberProperty([Business], "[20PROFIT_CTR__ZBBUSINES]")},

Anonymous
Not applicable

Seems like you almost have it in your last line. But shouldn't the rename follow the initial pattern, like instead of

{"Business.Business Level 01", "Business"}},

 

{"Business.Business Level 01", "Business.NewColumnName"}},


What are you trying to rename the column?

 

--Nate

Nope, that gives the same error:

 

Expression.Error: We expected newColumnNames to have the same number of items as attributeNames.
Details:
[List]

 

With the current code, the name displayed is Business.Business Level 01.  The "." is not treated as a delimiter or anything, it is simply just text.  

 

 

FredQ
Frequent Visitor

Of course I can rename it in the next line of M Code, but Microsoft says I can do it in this same line.  

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.