Forum Discussion
Anonymous
5 years agoNot 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?
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 _resultPlease 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
2 Replies
- AlBCommunity Champion
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 _resultPlease 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
- AnonymousNot applicable
Ah!! I knew it would be something simple. Worked like a charm, thanks so much!!