Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
McLaughlinMatt
Contributor II
Contributor II

Switch... Case for coloring Sankey chart

I have a Sankey chart with a bunch of nodes that I want to assign different colors. I could probably do it in a pinch with nested if statements, but that's an ugly ugly kludge. What I want to do is use a Switch statement like you would in just about any other programming language... like this:

SWITCH

CASE 'A' Red();

CASE 'B' Blue();

CASE 'C' Green();

DEFAULT Black()

END SWITCH

 

Does anyone know why SWITCH isn't available for color expressions? Or if there's a switch-like statement that I'm not finding?

Labels (5)
2 Replies
skamath1
Creator III
Creator III

Check if you can use Pick function.  If requires n as integer 

pick(n, expr1[ , expr2,...exprN])

pick(numcolor, Red(),Blue(),Green(),Black()) 

where numcolor = 1,2,3,4.. 

1 will return Red()

2 will return Blue() 

3 will return Green()

4 will return Black()

 

Check the help for more details

https://help.qlik.com/en-US/sense/June2019/Subsystems/Hub/Content/Sense_Hub/Scripting/ConditionalFun...

 

 

dwforest
Specialist II
Specialist II

You can use pick() with match() on the node dimension:

=pick(match([Encounter Outcome],'Positive','Presumed Recovered','Recovered','Expired','Self Isolated'),'#FF0000','#00C016','#00FF40,'#C0C0C0','#0000FF')