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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Expression.SyntaxError: Token RightParen expected. // Needing Help with a custom function

Hi there, so i'm writing this simple code to help me out with a problem when dealing with a Sheet..

 

So i have this 8 format number like this for example : 04777020 where i need to convert into a Postal code format like this 04777-020

But the thing is, some of the numbers lost the 0 which can usually be in front of the Postal Code, leaving it only with length of 7... soo i need to add this 0 again in the front of the code and i Need to add the 0 and add the - after the number in the 5th position, how can i do it?

 

Until now i writed this

 

= Table.AddColumn(#"Changed Type1", "Custom", each if Text.Length([CEP]) = 8 then Text.Insert([CEP],5,"-") else Text.Insert([CEP],1,"0")

 

ChangedType 1 is where i changed the column format to Text and [CEP] is where my codes are. and this error is showing up

 

Expression.SyntaxError: Token RightParen expected.

 

neardll_0-1657288098448.png

 

 

 

1 ACCEPTED SOLUTION

It needs to go at the very end of the line, not in the middle

View solution in original post

6 REPLIES 6
Alexis_Sawyer
New Member

Hola,

 

Tengo la siguiente consulta con el error " Se esperaba el token RightParen" en la coma marcada en rojo. Por favor ayúdenme a resolverlo.

 

la consulta es:

 

    Origen = Odbc.DataSource("dsn=IWS", [HierarchicalNavigation=true]),

    dbo_Schema = Origen{[Nombre="dbo",Kind="Esquema"]}[Datos],

    Ges_OrdenesCompra_Table = dbo_Schema{[Nombre="Ges_OrdenesCompra",Kind="Tabla"]}[Datos],

    Table.SelectRows = (Ges_OrdenesCompra_Table ,  cada [dato] >= #datetime(2022, 1, 1, 0, 0,0)),

    Table.SelectColumns = (Filas filtradas, {"VendAccount", "VendName"})

 

    Columnas filtradas

HotChilli
Super User
Super User

We've all done it and you're going to kick yourself when you solve it.

If I said Right paren means right bracket or closing bracket ......

---

As to the algorithm, I have 2 suggestions:

1. Maybe use Add column  ->Column from examples  to see if powerbi can help.

2. If you don't get it that way, have a look at Text.PadStart() function

 

Good luck

Anonymous
Not applicable

Thanks for your reply, i'll have a look in your sugestions and about the sugestions

 

1 - Soo.. i've tried the column from examples and it kinda worked for some values, but not for all fo them. Most because there are some codes that start with 2 zeros.. or 3, or 4 or even that start with 0 and then add a normal number like 1... soo it creates a lot of variants that PBI cant figure out what to do since if it starts with an 0 he automatically discart the number. Also, I could adapt all these variants one by one, but the problem is that pbi in this add column by examples have a limited visualization where i cant solve all of these

 

2 - the point is using Text.PadStart instead of Text.Insire?

johnt75
Super User
Super User

You're missing the ) at the very end to close the Table.AddColumn function

Anonymous
Not applicable

it still shows the error and now at the added ( 

neardll_0-1657290683444.png

 

It needs to go at the very end of the line, not in the middle

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.