Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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
Employee
Employee

Re: Re: Re: Set color on basis of condition

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

9 Replies
qlikoqlik
Contributor II

Re: Set color on basis of condition

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

Re: Set color on basis of condition

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.

Employee
Employee

Re: Set color on basis of condition

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

Not applicable

Re: Set color on basis of condition

Sure

Not applicable

Re: Set color on basis of condition

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

Employee
Employee

Re: Set color on basis of condition

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

Not applicable

Re: Re: Set color on basis of condition

This is my qvw File.

I am comparing two teams data.

Thanks Saurabh

Employee
Employee

Re: Re: Re: Set color on basis of condition

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

Re: Set color on basis of condition

Thanks.

It worked.

Community Browser