Qlik Community

QlikView Connectivity

Discussion board for collaboration related to QlikView Connectors.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
pinky1234
Contributor III
Contributor III

Colour issue in Pie chart

Hi ,

I am trying to apply the colors conditionally so writing a expression to achieve this.

Pick(Match(Id='Apple','Bird','Other'),Red(),Blue(),Green()). But i see black color by default. I dont want to see black colour in my chart and want to show conditionally colors that i mentioned in the formula. Can some one help me on this? Attached my qvw. 

1 Solution

Accepted Solutions
rwunderlich

A couple of issues. First, syntactically, there should not be a = in your Match(), that should be a comma. 

Pick(Match(Id,'Apple','Bird','Other'),Red(),Blue(),Green())

However that won't work because your Id values are not "Apple" etc, they are A, B, C, D, E and you are putting them in buckets with a calculated Dimension. But you can't reference the Calculated value in the background expression. You need to write it like:

Pick(Max(WildMatch(Id,'A','B','*')),Red(),Blue(),Green()) 

I used Max(WildMatch) as a way to avoid writing Green() three times. That might not match your real case. 

Another approach is to just paste your calculated Dim expression in as the Match() value.  That would work in this case, but only if you rewrote your calculated expression as:

=Aggr(If(Id='A','Apple',if(Id='B','Bird',If(Max(Match(Id, 'C','D','E')),'Other'))), Id) 

and then:

Pick(Match(Aggr(If(Id='A','Apple',if(Id='B','Bird',If(Max(Match(Id, 'C','D','E')),'Other'))), Id)
,'Apple','Bird','Other'),Red(),Blue(),Green())  

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

1 Reply
rwunderlich

A couple of issues. First, syntactically, there should not be a = in your Match(), that should be a comma. 

Pick(Match(Id,'Apple','Bird','Other'),Red(),Blue(),Green())

However that won't work because your Id values are not "Apple" etc, they are A, B, C, D, E and you are putting them in buckets with a calculated Dimension. But you can't reference the Calculated value in the background expression. You need to write it like:

Pick(Max(WildMatch(Id,'A','B','*')),Red(),Blue(),Green()) 

I used Max(WildMatch) as a way to avoid writing Green() three times. That might not match your real case. 

Another approach is to just paste your calculated Dim expression in as the Match() value.  That would work in this case, but only if you rewrote your calculated expression as:

=Aggr(If(Id='A','Apple',if(Id='B','Bird',If(Max(Match(Id, 'C','D','E')),'Other'))), Id) 

and then:

Pick(Match(Aggr(If(Id='A','Apple',if(Id='B','Bird',If(Max(Match(Id, 'C','D','E')),'Other'))), Id)
,'Apple','Bird','Other'),Red(),Blue(),Green())  

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com