Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set color on basis of condition

I am comparing data of two baseball teams and I want second team's data color on basis of data of first team

Example If first team have win/loss ratio = 1.42 and second team have win/loss ratio 2.00 then second team's ratio must be in green color if it is greater than that of first and red if less than that of first.

Here, both teams have different states(not the default one,i.e., inherited)

Win/Loss Ratio for first team is calculated as-

avg(aggr(avg({p7}Win_Loss_Ratio),TeamID))

Please Help.

Thanks in Advance.

(Attaching Image for reference)

1 Solution

Accepted Solutions
JonnyPoole
Employee
Employee

great.  I added the SET STATEMENT to the outer avg() function as well:

=if(avg( {p7}aggr(avg({p7}Win_Loss_Ratio),TeamID))>(avg( {p8} aggr(avg({p8}Win_Loss_Ratio),TeamID))),Red(255),Black(255))

It seems to work now.

score.PNG.png

View solution in original post

9 Replies
qlikoqlik
Creator
Creator

Hi Saurabh

You can set the text colour in the expression, expand the + sign and define your logic in there against text colour

Hope this works

Thanks

Padma

Not applicable
Author

In the presentation tab of Win/loss ratio graph, I have specified the calculated color as follows-

=if(avg(aggr(avg({p7}Win_Loss_Ratio),TeamID))>(avg(aggr(avg({p8}Win_Loss_Ratio),TeamID))),Red(255),Black(255))

Here, <> is working but not greater than or less than.

JonnyPoole
Employee
Employee

do you want to share the QVW to take a closer look ?

Not applicable
Author

Sure

Not applicable
Author

Actually, I have tried to do so but unable to drag and drop and there is no option to attach the file.

If you can tell me how to attach my qvw, it will be beneficial for me.

2.PNG

3.PNG

p7 and p8 represent state of first and second team correspondingly.

Thanks

JonnyPoole
Employee
Employee

When you reply hit 'use advanced editor' and then you can upload files.

Not applicable
Author

This is my qvw File.

I am comparing two teams data.

Thanks Saurabh

JonnyPoole
Employee
Employee

great.  I added the SET STATEMENT to the outer avg() function as well:

=if(avg( {p7}aggr(avg({p7}Win_Loss_Ratio),TeamID))>(avg( {p8} aggr(avg({p8}Win_Loss_Ratio),TeamID))),Red(255),Black(255))

It seems to work now.

score.PNG.png

Not applicable
Author

Thanks.

It worked.