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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Need help to correct a syntax error in my power query formula

Admitedly I am new to Power Query, I am trying to cleanse an internal database full of duplicate entries. I'm currently stuck at this step to transform the data. 

Problem:

I'm encountering an "Expression.SyntaxError: Token expected ','" error while attempting to create a new column in Power Query Editor. The formula I'm using is:

= Table.TransformColumns(#"Previous Step Name", {{"Trader Uid", each {Account Name} & " " & Text.Clean([Postcode]), type text}})

Context:

I'm working on a data cleaning and transformation task in Power BI. The goal is to create a new column "Trader Uid" by combining the values from the "Account Name" and "Postcode" columns. Seems simple enough but repeatedly getting this error upon various changes to formula. 

Troubleshooting Steps Taken:

  1. Verified Column Names: I've double-checked the column names to ensure they match the actual names in the data.
  2. Checked Data Types: I've confirmed that the data types of the columns are compatible for concatenation.
  3. Reviewed Previous Step: I've verified that the name of the previous step is correct.

Possible Causes and Solutions: The error could be down to my limited Power Query syntax knowledge or data quality or something else. 

Request for Assistance:

I would appreciate any guidance or suggestions from the Power BI community to resolve this issue. Please provide any specific tips or troubleshooting techniques that might help identify and correct the syntax error.

Additional Information:

  • Data Source: [My data source is multiple Excel file data exported out of our Salesforce]
  • Relevant Data Sample: Here's a small sample of data where my expected outcome is Sl#4, 7 - is a duplicate. 
    Sl Nr.Account NamePostcodeTrader UidBilling Address Line 1
    1ArgosKA12 8BHArgosKA12 8BHAyr Road
    2ArgosG15 6RXArgosG15 6RX10 Alerdyce Road
    3Arnold ClarkPH1 3GAArnold ClarkPH1 3GA
    Clark Superstore The Triangle
    4Arnold ClarkG32 9QQArnold ClarkG32 9QQ5 Hamilton Rd
    5Arnold ClarkG20 7LDArnold ClarkG20 7LDArnold Clark 53
    6Arnold ClarkEH11 4DJArnold ClarkEH11 4DJ1 Bankhead Drive
    7Arnold ClarkG32 9QQArnold ClarkG32 9QQ5 Hamilton Rd
    8Arnold ClarkAB16 6HTArnold ClarkAB16 6HT
    Clark Autos Ltd Whitemyres Place
    9TescoPA15 1AATescoPA15 1AATesco Extra Ayr
    10MorrisonsG42 9AEMorrisonsG42 9AEMorrisons Polloks
    11AldiG41 2AAAldiG41 2AAAldi Shawlands
    12LidlG41 2AALidlG41 2AALidl Shawlands
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

Thanks for the solution ZhangKun  and jgeddes  offered, and i want to offer some mroe information for user to refer to.

hello @Anonymous , you can click the 'Accout Name' and 'Postcode' columns,  then click merged columns in 'Add column' tab

vxinruzhumsft_0-1733451899506.png

Then select split them by using the space.

vxinruzhumsft_1-1733451977710.png

 

Output

vxinruzhumsft_2-1733451993757.png

Best Regards!

Yolo Zhu

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

5 REPLIES 5
Anonymous
Not applicable

Hi,

Thanks for the solution ZhangKun  and jgeddes  offered, and i want to offer some mroe information for user to refer to.

hello @Anonymous , you can click the 'Accout Name' and 'Postcode' columns,  then click merged columns in 'Add column' tab

vxinruzhumsft_0-1733451899506.png

Then select split them by using the space.

vxinruzhumsft_1-1733451977710.png

 

Output

vxinruzhumsft_2-1733451993757.png

Best Regards!

Yolo Zhu

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

 

 

ZhangKun
Super User
Super User

Let's talk about your problem first:

1. The Table.TransformColumns function can only access the current column. For {x, each _}, only the value of column x can be accessed, and other columns cannot be accessed.

2. Text.Clean removes characters with ASCII codes 0 to 30 and 127. If you need to remove blanks, please use Text.Trim (it can only remove blanks at both ends). If you need to achieve your requirements, you can use the following formula:

 

let
    #"Previous Step Name" = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rZJRb4IwFIX/yg3PPlAQ1Mc6CGRziSLJlhAfGttIY6VLi9v89yt1jgo+LoHQ8917Tml6q8pD3sTD6iC1+b5gFMB8md+Qqy8KCkmot5tUXuB4MhRBXLzfSC+RD1gwRS971jtD29dIQeFJEHU0cp0jCDM8KPTU+iyD7fmDKd1KxaCszas4aQ6CdU1/T9c9He+ShQEsNptBoacR5OTERSsbKK6/Gj0ICXyYrZJhyEMKUWhj4nFMmiME0+R5UHEwgiVpjjUjFBLFP5lNmv3HqebjELxEMcR5Oag42LkCfG6lhlVL4a3mLTtdFNOwFmQ/voWFWZRM72V3ydjMBcL4hoYa0u9WETBTZq3IN4VXqRTXsrFTNjVHwqlLHyBYSyHkUV8z7GQLyq0dQWB368C9gm1NvgRp6K+tG+4Vp+LO1oF75dp2Pw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Sl Nr." = _t, #"Account Name" = _t, Postcode = _t, #"Trader Uid" = _t, #"Billing Address Line 1" = _t]), 
    Replace = Table.ReplaceValue(#"Previous Step Name", each Text.Trim([Account Name] & " " & Text.Clean([Postcode])), null, (val, old, new) => old, {"Trader Uid"})
in
    Replace

 

Text.Trim is used in the formula to remove the spaces generated by two blank lines.

jgeddes
Super User
Super User

From the screenshots I see a couple of things. 
Table references cannot contain spaces.

In the screenshot, Renamed Columns should be #"Renamed Columns". 

Column references with non-alpha numeric characters need to be entered the same way. So [Billing Zip/Postal Code] should be [#"Billing Zip/Postal Code"].





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





jgeddes
Super User
Super User

Adding a column should have the code...

Table.AddColumn(previousStepName, "Trader Uid", each [Account Name] & Text.Clean([Postcode]), type text)

In your code you appear to be attempting to transform an existing column. I would guess the error in your code is due to {Account Name}. It should be [Account Name].

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Anonymous
Not applicable

Thanks @jgeddes for providing a responce with a sample code. Strangely I still get error - see screenshot-1 (same syntax error as before) when I try to add new column, or to transform an existing column (screenshot-2): invalid identifier. 

adssails_0-1733328712647.png 

adssails_1-1733329391918.png

Revised code used:
Add: = Table.AddColumn(#"Renamed Columns", "Trader Uid", each [Account Name] & Text.Clean([Postcode]), type text)
Transform: = Table.TransformColumns(#"Renamed Columns", {{"Trader Uid", each [Account Name] & " " & Text.Clean([Postcode]), type text}})

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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