0

This is from the Coursera Power BI course. I'm trying to create a create a "Sales in USD" calculated table. I was instructed to select a New Table in Power BI and type the following:

Sales in USD =  
     ADDCOLUMNS(
        Sales,
        "Country Name", RELATED(Countries[Country]),
        "Exchange Rate", RELATED('Exchange Data'[Exchange Rate]),
        "Exchange Currency", RELATED('Exchange Data'[Exchange Currency]),
        "Gross Revenue USD", [Gross Revenue] * RELATED('Exchange Data'[Exchange Rate]),
        "Net Revenue USD", [Net Revenue] * RELATED('Exchange Data'[Exchange Rate]),
        "Total Tax USD", [Total Tax] * RELATED('Exchange Data'[Exchange Rate])
    )

It generated "The following syntax error occurred during parsing: Invalid token, Line 3, Offset 2,  ."

I've looked online for how the ADDCOLUMNS function is used, and the code above seemed to comport with the explanations that I read online.

What am I - I mean Coursera - doing wrong?

2 Answers 2

0

I suspect some of the quotes and apostrophes may be "dirty" or there are some invisible whitespace characters. This happens sometimes when copying/pasting code from websites.

Try copying/pasting the below or from your question.

Sales in USD =  
  ADDCOLUMNS(
    Sales,
    "Country Name", RELATED(Countries[Country]),
    "Exchange Rate", RELATED('Exchange Data'[Exchange Rate]),
    "Exchange Currency", RELATED('Exchange Data'[Exchange Currency]),
    "Gross Revenue USD", [Gross Revenue] * RELATED('Exchange Data'[Exchange Rate]),
    "Net Revenue USD", [Net Revenue] * RELATED('Exchange Data'[Exchange Rate]),
    "Total Tax USD", [Total Tax] * RELATED('Exchange Data'[Exchange Rate])
  )

If that doesn't work, then please update your question with a screen grab of your expression in Power BI. The wavy red-underlines should hopefully help identity the culprit.

Sign up to request clarification or add additional context in comments.

Comments

0

I'm trying to get this same script in the Coursera's final project to work too and it won't. This isn't the first time the code or files I downloaded for this course don't work, but in the second half of this project they make us create measures based on this table, so it's hard to skip around this.

I got mine to work. You need to fix the squiggly red lines because the syntax for the tables aren't named right. Look at mine:

Sales in USD = 
ADDCOLUMNS(
    Sales,
    "Country Name", RELATED(Countries[Country]),
    "Exchange Rate", RELATED('Exchange Data'[ExchangeRate]),
    "Exchange Currency", RELATED('Exchange Data'[Exchange Currency]),
    "Gross Revenue USD", [Gross Revenue] * RELATED('Exchange Data'[ExchangeRate]),
    "Net Revenue USD", [Net Revenue] * RELATED('Exchange Data'[ExchangeRate]),
    "Total Tax USD", [Total Tax] * RELATED('Exchange Data'[ExchangeRate])
)

Mine is fine now.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.