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
T1moris
New Member

Cannot reference column renamed to Week#(2) in Power Query (invalid identifier)

In Power BI (Power Query), I tried to rename a column and ran into a strange issue.

When I rename the column to Week#(2) , the automatically generated M code is:

 

Renamed Columns2 =Table.RenameColumns(#"Expanded Maxim",{{"Week#.1", "Week#(#)(2)"}})


Later, when I write a new step and try to reference this column, I always get an “invalid identifier” error, no matter which name I use:

[Week#(2)]

[Week#(#)(2)]

Both give me an error.

 

Why is Power Query changing the name to Week#(#)(2) internally?

How am I supposed to correctly reference this column in later steps?

Is there something special about the # character or the parentheses in column names in Power Query / M?

 

Thanks in advance for any explanation or workaround!

4 REPLIES 4
Omid_Motamedise
Super User
Super User

Hi @T1moris 

 

Power Query has two different concepts:

Display name (what you see in the UI) => Week#(2)

M language identifier (what the engine must use internally)

M has strict identifier rules. A column name can be referenced directly only if it: Starts with a letter or underscore and Contains only letters, numbers, and underscores

Your column name: Week#(2) violates three rules: # is special in M ( and ) are not allowed in identifiers

In M: #"Some Text" means “treat this text literally as a name” So when Power Query internally generates: "Week#(#)(2)"

The column name contains literal text Week#(2), and the # itself must be escaped This is not a rename mistake—it’s Power Query protecting itself from syntax errors.


Why do [Week#(2)] and [Week#(#)(2)] both fail?
Because square brackets only work for valid identifiers. This works: [SalesAmount] and This fails: [Week#(2)]

Because Week#(2) is not a valid identifier, even if that looks like the column name.

The CORRECT way to reference this column is: [#"Week#(2)"]

 


If my answer helped solve your issue, please consider marking it as the accepted solution.
ronrsnfld
Super User
Super User

Because you have "special" characters within your new name, and even nested special characters, you need to escape those characters:

#"Week#(#)(2)"

 

Example:

 

ronrsnfld_0-1766662884665.png

 

 

 

ralf_anton
Helper I
Helper I

Hallo,

wenn Du Sonderzeichen in den Spaltennamen benutzt, müssen diese bei der Auswertung mit #"..." maskiert werden. Beispiel:

 

#"Umbenannte Spalten" = Table.RenameColumns(Quelle,{{"Woche 2", "Woche #(#)(2)"}}),
wert = #"Umbenannte Spalten"[#"Woche #(#)(2)"]{0}

 

Im Prinzip analog zur Verwendung bei Abfrageschrittnamen mit Sonder- oder Leerzeichen.

Besser ist es daher, auf Sonder- und Leerzeichen zu verzichten.

cengizhanarslan
Continued Contributor
Continued Contributor

# and parentheses are the issue, and what you’re seeing is Power Query trying to “escape” characters that have meaning in M.

 

In M, #(...) is used in special literals (like #date(2025,1,1) or #duration(...)).
So when you put #( inside a column name (Week#(2)), the rename UI tries to escape it and you end up with the weird internal text Week#(#)(2).

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn

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.