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
Anonymous
Not applicable

DAX - the syntax for RETURN is incorrect.... why it is showing this error?

hi all,

please check what is the problem as I failed to understand it as I have copied this code from a video to implement with little modifications:  Video Guide Link 

 

the Data is date wise dollar price and wants to have % Change.

 

screenshot:

Core2Plus_0-1622809372929.png

the code:

Pct Change =
VAR CurrentValue = CALCULATE(VALUES('Big Mac Index'[dollar_price]))
VAR PreviousValue =
SWITCH(
TRUE(),
ISINSCOPE('CalDates'[Date], CALCULATE(VALUES('Big Mac Index'[dollar_price]), DATEADD('CalDates'[Date], -1, DAY))
)
RETURN
DIVIDE(
CurrentValue - PreviousValue,
PreviousValue
)

 

regards

 

1 ACCEPTED SOLUTION

I use daxformatter, it also format the dax code and give you pointer loacation about the error happened
https://www.daxformatter.com/

sqlbi.png

You can also download the dax tools from sql bi webite to work offline

View solution in original post

5 REPLIES 5
v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

You are missing a closing parenthesis , so the formula will report an error .

Ailsa-msft_0-1623054409081.png

You can use the daxformatter to format the dax code and check the location of error .

https://www.daxformatter.com/

  

Best Regards

Community Support Team _ Ailsa Tao

 

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

amitchandak
Super User
Super User

@Anonymous , I think missing parenthesis causing this

 

Pct Change =
VAR CurrentValue = CALCULATE(VALUES('Big Mac Index'[dollar_price]))
VAR PreviousValue =
SWITCH(
TRUE(),
ISINSCOPE('CalDates'[Date]), CALCULATE(VALUES('Big Mac Index'[dollar_price]), DATEADD('CalDates'[Date], -1, DAY))
)
RETURN
DIVIDE(
CurrentValue - PreviousValue,
PreviousValue
)

Anonymous
Not applicable

thanks a lot @amitchandak for help 🙂 what experts are using to debug / check find error? is there any tool or its your great Brain and experiences? if any tool, can you please share the name with us? 

regards

I use daxformatter, it also format the dax code and give you pointer loacation about the error happened
https://www.daxformatter.com/

sqlbi.png

You can also download the dax tools from sql bi webite to work offline

Anonymous
Not applicable

thanks @amikm , will defenitely check this.

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.