Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

reivax31
Contributor III

Set color to background depending on variable value

Hi Qlikers,

I would like de set the background of my simple KPI depending on the value of my variable.

I have a variable that allow me to select a date. And for each date there is a specific location for each Type (see data in attached App).

What I want, is that once a Type is selected and a variable (vFlexDate) is set to a value the background of the correct location is set to green. for now it only works if y filter on MyDate and set it to the same value as vFlexDate.

Is there a way to set the background to green without filtering on MyDate?

07-06-2017 13-35-03.jpg

To try the App attached it is needed to have variable and Simple KPI extensions

Thanks for your support

8 Replies
tajmohamed30
Contributor III

Re: Set color to background depending on variable value

chooco_co
Valued Contributor

Re: Set color to background depending on variable value

Hi Xavier,

Is date from your table impact the color? or only at variable that change the color?

If you want to trigger user to pick date from your variable and choose location so the color show up.

I change your background color at simplekpi into this one.

=if(vFlexDate<>null() and Location='A2', GREEN(), WHITE())

Hope this helps

Regards,

Marco

reivax31
Contributor III

Re: Set color to background depending on variable value

Hi,

Basicaly here is what I want. When user trigger a date (meaning variable vFlexDate is set to a value) I want to highlight the location by changing the background of A1 or A2 depending on where my selected type was located base on the data set in my App.

Let me know if it's clear enough

Best regards

reivax31
Contributor III

Re: Set color to background depending on variable value

As you can see if I only select Type and a date on my variable buttons the background of Location A1 is not set to green. To set it to green I have also the select in my data set Mydate=08/06/2017. But I don't want to have to filter on Mydate, I would like it to work by using only variable buttons.

07-06-2017 14-50-30.jpg

chooco_co
Valued Contributor

Re: Set color to background depending on variable value

Hi Xavier,

I'm still not understand what you wanna do, what i got like this

1. You have variable to trigger a date

2. You have simple KPI which is you want it can change the background

My question:

1. What condition trigger to change the background color?

2. is it simple kpi trigger to change background color on table?

But rather than you use variable, you can use the script to create a new field change current date as today, and then you can use new field as your condition.

I think it's easier rather than using variable.

Regards,

Marco

chooco_co
Valued Contributor

Re: Set color to background depending on variable value

Hi Xavier,

What you want is when you select the variable then your date should selected to right?

I think better you should add new field like my explanation above.

Regards,

Marco

reivax31
Contributor III

Re: Set color to background depending on variable value

Right now my expression for the background is:

=if(MyDate=vFlexDate and Location='A1', GREEN(), WHITE())

But this doesn't work, because I have to filter on MyDate to make the background changed to green. But for other reason I don't want to filter on MyDate as this will make other KPI not work.

07-06-2017 15-32-47.jpg

chooco_co
Valued Contributor

Re: Set color to background depending on variable value

Hi Xavier,

Try this expression

=if(vFlexDate<>null() and Location='A2', GREEN(), WHITE())


Regards,

Marco

Community Browser