Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
alvaprajna
Partner - Contributor III
Partner - Contributor III

Change bar colour based on another dimension

Hi ,

I have following data,

Country,entity,class,score

Austria,1523,HIGH,5

Austria,1524,LOW,3

Bang,123,High,2

Bang,1234,Low,2

Denmark,1236,Medium,2

I have a bar chart with a drill down (country--> entity) as dimension and expression=max(Score)

I need to plot this in such a way that y-axis height is max score and bar color is based on class.

if(class=HIGH,red(),class=LOW,yellow()).

if the score is same then it must consider highest class,so in above case it can be high for country=Bang.

Kindly suggest.

I tried adding background expression as if(class=HIGH,red(),class=LOW,yellow()).The value for country is not shown as 5 since it has two values

5 Replies
sunny_talwar

May be this

If(FirstSortedValue(class, -Score) = 'HIGH', Red(),

If(FirstSortedValue(class, -Score) = 'LOW', Yellow()))

alvaprajna
Partner - Contributor III
Partner - Contributor III
Author

it may not be the first value always..if we have same score and the class is high and low then it should consider high,

if its low and medium then it should consider medium.if its low and high then it should high.

alvaprajna
Partner - Contributor III
Partner - Contributor III
Author

Okay i used a table adding risk value its working now.

one more isssue, Actually in dimension..i added

=if(TotalScore=aggr(max(TotalScore),[country]) ,[country],[entity])

so that it shows me all country with highest score in bar chart. and accordigly em getting colour based on class.

But noe i am facing a new issue,If the ountry has same score its giving the highest score..but colour is not set based on the class.May be due to common score its not able to decide the class.

Ex:

Country,entity,class,score

Poland,159,HIGH,3

Poland,158,LOW,3

its basically a drill down for ex: country--> entity.

alvaprajna
Partner - Contributor III
Partner - Contributor III
Author

In case the score is same its failing.

sunny_talwar

Would you be able to share a sample to take a deeper look at this?