Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
darrihilmarsson
New Contributor III

Background colour on button

Hi, QlikView Community

I am a simple dataset what you can look at in the excel file.

I have one trouble I am trying to solve regarding background color in button.

I have a button that has actions that is supposed to select two Company Codes (100 and 110).

Also I want the button to change colors when I push the button.

I want the button to change when the Company Codes are 100 and 110 and I want the button to change back when I deselect the company codes.

I tried this formula in the button calculated base color:

=If([Company Code] = '100' and [Company Code] = '110', RGB(0, 240, 16), RGB(15, 48, 99))

but it did not work. Do you have any ideas?

regards Darri

1 Solution

Accepted Solutions
pradeepreddy
Valued Contributor II

Re: Background colour on button

try like this..

=if(Concat(distinct [Company Code],',')='2008,2009',RGB(0, 240, 16), RGB(15, 48, 99))

11 Replies
Partner
Partner

Re: Background colour on button

HI,

Try this

=if(len(GetFieldSelections([Company Code])) > 0,RGB(0, 240, 16), RGB(15, 48, 99))

-Sathish

Partner
Partner

Re: Background colour on button

sinanozdemir
Valued Contributor III

Re: Background colour on button

Hi,

I used a variable, please see the attached.

Thanks

Re: Background colour on button

Use match instead

     if(match([Company Code], 100, 110), RGB(0, 240, 16), RGB(15, 48, 99))

darrihilmarsson
New Contributor III

Re: Background colour on button

The button becomes green when I select every company code.

I only want it to become green when I select both company code 100 and 110.

And I want it to become blue again when I select something else e.g. company code 130

how can I do that

darrihilmarsson
New Contributor III

Re: Background colour on button

The button becomes green when I select either company code 100 or 110.

But when I select both 100 and 110 the button becomes blue

I only want it to become green when I select both company code 100 and 110.

how can I do that?

Partner
Partner

Re: Background colour on button

Hi there,

Two methods for you... Method 1 works perfectly I believe:

I changed the colour to be calculated as follows:

=if(num(TextBetween(GetFieldSelections([Company Code]),'(','|')&TextBetween(GetFieldSelections([Company Code]),'|',')'))=100110,RGB(0,240,16),RGB(15,48,99))

This makes sure that those specific values have been selected.  Button changes perfectly.

Alternatively:

I changed the color to be calculated on whether the sum of the Country Code when 100 and 110 are selected is equal to the sum of the rest not being selected.

if(sum({$<[Company Code] =- {'120','130','140'}>}[Company Code])=sum([Company Code]),RGB(0,0,0),RGB(155,155,155))

Problem here is if you select two other fields and they by chance equal the same as 100 and 110 it changes as well.  So I think method 1 is preferable.

Hope this helps

Re: Background colour on button

May be try this

If ( Concat(Distinct  [Company Code],':')='100:110',rgb (0,255,0),rgb (0,0,255))

Partner
Partner

Re: Background colour on button

Hi Darri,

nearly there, try:

If(GetFieldSelections([Company Code])='(100|110)',RGB(0, 240, 16), RGB(15, 48, 99)) 

HTH Andy