Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
So I know how to set fixed colors in the background part of the expression, but am unsure how to get them to stick in a chart when using grouped dimensions.
There are 3 different dimensions in the group and each field of each dimension has an assigned color code. I used this in the background color expression and it almost does what I need
if(len(Sentiment),if(not IsNull(SR), RGB(SR,SG,SB)),
if(len([Media Type]),if(not IsNull(MR), RGB(MR,MG,MB)),
if(len(Topic),if(not IsNull(TR), RGB(TR,TG,TB)))))
Here's how it looks. The bars change to the appropriate color as the other two pie charts when I switch to those dimensions. So when its sentiment, the colors will be green, grey, yellow and red, as they are supposed to.
The problem is that if I filter down to 1 field or if only one of those fields is represented in any of those dimensions the color defaults to one of the other dimensions colors. For example, here I filtered down to Sentiment = Positive
So now even when its still set to show the dimension of Topic all the topics despite still being split out are changed to the same color. I tried changing the order of the expression, but that only fixes it for certain situations and still causes errors in others.
Anyone have any ideas as to work around this? Basically I need the color expression to be fixed to only the current dimension of the group being displayed.
When you select a single Sentiment, then that field has a value in all of your charts. So anything wanting the Media Type or Topic color is going to get the Sentiment color instead since that's the first if(). Similarly, if you select a single Media Type, that will override the Topic colors, but not the Sentiment colors.
Rather than checking for values in the fields, check which dimension you're currently using with getcurrentfield(). I'd also use a pick(match()) rather than repeated ifs. I'd also check len(SR) instead of not isnull(SR) due to implementation problems of isnull() in some versions of QlikView. So this:
pick(match(getcurrentfield("Topic/MediaType/Sentiment")
,'Sentiment','Media Type','Topic')
,if(len(SR),RGB(SR,SG,SB))
,if(len(MR),RGB(MR,MG,MB))
,if(len(TR),RGB(TR,TG,TB)))
It seems to work, though I'm not familiar enough with what you're doing to be 100% confident.
Hi,
Did you try using "Persistant Colours" and "Repeat Last Colour"? (I don't know if it is real name, because i have spanish version, but is in Graph / Properties / Colours..)
U Should check them in all the objects you want to see the same colours. Please, delete the format expressions of the expressions.
Tell me if it was useful for you.
Unfortunately that won't work because the colors need to be specific to fields. ie, for media types twitter always needs to be light blue and for sentiment positive always needs to be green.
Because of that, I can't really use the same color palete across the different dimensions. If that was not the case your solution would have worked. Thanks!
Ok. The image you send is not visible...
Could you reduce and send the qvw?
Here you are.
When you select a single Sentiment, then that field has a value in all of your charts. So anything wanting the Media Type or Topic color is going to get the Sentiment color instead since that's the first if(). Similarly, if you select a single Media Type, that will override the Topic colors, but not the Sentiment colors.
Rather than checking for values in the fields, check which dimension you're currently using with getcurrentfield(). I'd also use a pick(match()) rather than repeated ifs. I'd also check len(SR) instead of not isnull(SR) due to implementation problems of isnull() in some versions of QlikView. So this:
pick(match(getcurrentfield("Topic/MediaType/Sentiment")
,'Sentiment','Media Type','Topic')
,if(len(SR),RGB(SR,SG,SB))
,if(len(MR),RGB(MR,MG,MB))
,if(len(TR),RGB(TR,TG,TB)))
It seems to work, though I'm not familiar enough with what you're doing to be 100% confident.
Looks like it works perfectly! Thanks!
An additional question.
When I use the hard coded colors in the bar charts topics that don't have assigned colors default to the standard Qlikview colors, which is fine. But in pie charts they turn black. Any idea why it only seems to impact pie charts in that regard and if there is any work around for it?
Thanks again.
I don't know why it only impacts pie charts, but one workaround would be to assign random colors to unidentified topics/mediatypes/sentiments in the script. See attached for an example.