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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dvnnvd
Regular Visitor

Please can someone check this formula?

Hi Guys,

 

I'm trying to create a custom column to calculate adecemic year based on columns in my existing table...

 

if([month_logged] >= 8,[year_logged]&"-"&right([year_logged]+1,2), [year_logged]-1&"-"&right([year_logged],2))

 

However I seem to run into an error saying "Token RightParen expected". I'm sure I probably have the forumula wrong but I'm not sure how to take the above and make it work in Power BI.

2 ACCEPTED SOLUTIONS
vanessafvg
Super User
Super User

@dvnnvd

 

heck my code in daxformatter, http://www.daxformatter.com/

 

normally indicates if there is an issue

 

when i put your code in there it doesnt seem to have any syntax issues, i am assuming you created this as a calculated column.  Try breaking down each part of the code and see what you get

 

ie. i always put a column or measure name in the formatter otherwise it will take issue with it

 

test =
IF (
    [month_logged] >= 8,
    [year_logged] & "-"
        & RIGHT ( [year_logged] + 12 ),
    [year_logged] - 1
        & "-"
        & RIGHT ( [year_logged], 2 )
)





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

danextian
Super User
Super User

hi @dvnnvd,

 

Token RightParen expected. You seem to be creating a custom column in power query instead of creating a calculated one in DAX. They have different syntaxes. Attaching a screenshot of the error would be great.










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

hi @dvnnvd,

 

Token RightParen expected. You seem to be creating a custom column in power query instead of creating a calculated one in DAX. They have different syntaxes. Attaching a screenshot of the error would be great.










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
vanessafvg
Super User
Super User

@dvnnvd

 

heck my code in daxformatter, http://www.daxformatter.com/

 

normally indicates if there is an issue

 

when i put your code in there it doesnt seem to have any syntax issues, i am assuming you created this as a calculated column.  Try breaking down each part of the code and see what you get

 

ie. i always put a column or measure name in the formatter otherwise it will take issue with it

 

test =
IF (
    [month_logged] >= 8,
    [year_logged] & "-"
        & RIGHT ( [year_logged] + 12 ),
    [year_logged] - 1
        & "-"
        & RIGHT ( [year_logged], 2 )
)





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Thank you,

 

I have done this but the main errors in my code seem to come from the use of "(" and ",". e.g. the Dax formatter throws the following errors

 

Syntax error, expected: columnId    at line 1, col 4

Syntax error, expected: =, :=    at line 2, col 20

 

I think the code itself is okay, it's probably just my formatting so to speak. The code itself works fine in PowerPivot, just not Power BI.

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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