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

Dax command for conditional highlighting

Hi All,

 

I've been following along the Guy in a Cube video to set up conditional highlighting, and I've run into a problem with my dax code:

 

highlighting =
var _Source =
Values (Highlight[Source])
var _tohighlight =
SELECTEDVALUE('Trend_data'[Source])
var _Colour =
VALUES(Highlight[HTML_Colour])
Var _filtered =
ISFILTERED(Highlight[Source])
var _result =
SWITCH(
TRUE,
Not ( _filtered ), "#5BAF8D",
_tohighlight in _source
&& _filtered,"#5BAF8D",_Colour)
 
I'm getting an error which essentially says syntax for ')' and I can't work out where I've gone wrong! Is anything obvious jumping out at anyone?

 

 

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Anonymous 

You are missing the RETURN part, necessary when you use variables:

highlighting =
VAR _Source =
    VALUES ( Highlight[Source] )
VAR _tohighlight =
    SELECTEDVALUE ( 'Trend_data'[Source] )
VAR _Colour =
    VALUES ( Highlight[HTML_Colour] )
VAR _filtered =
    ISFILTERED ( Highlight[Source] )
VAR _result =
    SWITCH (
        TRUE,
        NOT ( _filtered ), "#5BAF8D",
        _tohighlight IN _Source
            && _filtered, "#5BAF8D",
        _Colour
    )
RETURN
    _result

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @Anonymous 

You are missing the RETURN part, necessary when you use variables:

highlighting =
VAR _Source =
    VALUES ( Highlight[Source] )
VAR _tohighlight =
    SELECTEDVALUE ( 'Trend_data'[Source] )
VAR _Colour =
    VALUES ( Highlight[HTML_Colour] )
VAR _filtered =
    ISFILTERED ( Highlight[Source] )
VAR _result =
    SWITCH (
        TRUE,
        NOT ( _filtered ), "#5BAF8D",
        _tohighlight IN _Source
            && _filtered, "#5BAF8D",
        _Colour
    )
RETURN
    _result

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Ah!! I knew it would be something simple. Worked like a charm, thanks so much!!

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.