cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SeanCalvert
New Member

The syntax for ')' is incorrect

Hello guys. Im trying to do a DAX command and I´m getting the following error.

 

What I´m trying to do is highlight teams based on their names (whenever I click one team, it will highlight it on a visual).

 

  • The table "Team_Highlight" only has the team names from the "Premier League" table
  • The table "Premier League" has information about the different Premier League teams

I will paste the DAX code and the error below: 

 

TeamToHighlight2 =
var _selectedteam =
VALUES( Teams_Highlight[Team Name] )
var _teamtohighlight =
SELECTEDVALUE( 'Premier League'[Team Name] )
var _filtered =
ISFILTERED( Teams_Highlight[Team Name] )
var _result =
SWITCH(
true,
not( _filtered ), "#0079EB",
_teamtohighlight IN _selectedteam
&& _filtered, "0079EB",
"#99C9F7"
)
 
Error: The syntax for ')' is incorrect. (DAX(var _selectedteam = VALUES( Teams_Highlight[Team Name] )var _teamtohighlight = SELECTEDVALUE( 'Premier League'[Team Name] )var _filtered = ISFILTERED( Teams_Highlight[Team Name] )var _result = SWITCH( true, not( _filtered ), "#0079EB", _teamtohighlight IN _selectedteam && _filtered, "0079EB", "#99C9F7"))).
 
Hope it works.
 
Thank you
1 ACCEPTED SOLUTION
daXtreme
Super User
Super User

It is what it is: you've got the syntax wrong. Head over to www.daxformatter.com, paste the code in there and let it check it. It'll show you where the problem is...

Spoiler
TeamToHighlight2 =
VAR _selectedteam =
    VALUES( Teams_Highlight[Team Name] )
VAR _teamtohighlight =
    SELECTEDVALUE( 'Premier League'[Team Name] )
VAR _filtered =
    ISFILTERED( Teams_Highlight[Team Name] )
VAR _result =
    SWITCH(
        TRUE,
        NOT ( _filtered ), "#0079EB",
        _teamtohighlight
            IN _selectedteam
            && _filtered, "0079EB",
        "#99C9F7"
    )
RETURN
    _result

 

View solution in original post

2 REPLIES 2
SeanCalvert
New Member

Thank you a lot for the help. I thought the solution was with the return clause but didn´t know what to return

daXtreme
Super User
Super User

It is what it is: you've got the syntax wrong. Head over to www.daxformatter.com, paste the code in there and let it check it. It'll show you where the problem is...

Spoiler
TeamToHighlight2 =
VAR _selectedteam =
    VALUES( Teams_Highlight[Team Name] )
VAR _teamtohighlight =
    SELECTEDVALUE( 'Premier League'[Team Name] )
VAR _filtered =
    ISFILTERED( Teams_Highlight[Team Name] )
VAR _result =
    SWITCH(
        TRUE,
        NOT ( _filtered ), "#0079EB",
        _teamtohighlight
            IN _selectedteam
            && _filtered, "0079EB",
        "#99C9F7"
    )
RETURN
    _result

 

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors