Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

paulyeo11
Valued Contributor II

Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

Hi All

I copy the this KPI from QS example , i dont know how to make the % change to red color when % is +ve ? Now it display black color , i need to make it display Red color when -ve. Now alway black.

I have try use the below expression , i insert at color value :-

=if([Sales vs Target] <0% ,'#d01919','#545352')

But it does not work.

Paul

1 Solution

Accepted Solutions
danansell42
Contributor III

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

As mentioned above, you haven't included the *-1 in the colour expression to finish of the simulation.

The colour expression evaluates separately from your main expression and is therefore still calculating a positive number.

I've just tested it and works perfectly for me.

Capture.PNG

Example for colour expression:

if(-1*if(

(

Sum({$<year = {$(=Max(year)-0)}, month = {"<=$(=Max({<year={$(=Max(year))}, sales = {'*'}>} month))"}>}sales/1000/Rate)

/

Sum({$<year = {$(=Max(year)-0)}, month = {"<=$(=Max({<year={$(=Max(year))}, sales = {'*'}>} month))"}>}sales_target/1000/Rate)

)

>1,1,

(

Sum({$<year = {$(=Max(year)-0)}, month = {"<=$(=Max({<year={$(=Max(year))}, sales = {'*'}>} month))"}>}sales/1000/Rate)

/

Sum({$<year = {$(=Max(year)-0)}, month = {"<=$(=Max({<year={$(=Max(year))}, sales = {'*'}>} month))"}>}sales_target/1000/Rate)

)

) >0 ,'#d01919','#545352')

24 Replies
paulyeo11
Valued Contributor II

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

My qvf

Not applicable

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

Hi Paul,

The app is showing invalid visualisation (the visualisation was not found on the server: qsSimpleKPI).

karunpreet
Contributor

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

Hi Paul,

you can change ur expression to the below expression:

=if([Sales vs Target] <0 ,RGB(255,0,0),RGB(0,255,0))


Note:

Change the RGB values according to the colour u want

paulyeo11
Valued Contributor II

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

‌Hi Karupreet

thank you for your reply , I will try this evening.

DOes it mean that QLIK VIEW script for Color expression is not same as KPI Sample ? Need to follow KPI Sample style of writing ?

PAul

paulyeo11
Valued Contributor II

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

‌HI Nhu

KPI Simpel is qlik sense extension.

in order to remove the error , you need to install KPI SIMPLE EXTENSION to your QS DESKTOP .

NEed to to downlod from qlik branch .

thank you for your help

paul

karunpreet
Contributor

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

Hi Paul,

What exactly is ur requirement ? you want to make the text colour change or the bar/ line colours?

If you want to the chnege the text colours then u need to write the same expression in

Right Cick -> Properties -> Font -> Colour -> Calculated Expression

and if you want to change the bar colour then

Right Cick -> Properties -> Expression -> Add your expression -> You will find a plus sign on the expression name, click on that -> colour -> paste the above expression


Regards

Karunpreet

paulyeo11
Valued Contributor II

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

Hi Karunpreet

Base on your reply , I think you refer qlik view right ?

Paul

Sent from my iPhone

karunpreet
Contributor

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

Yeah. But u can write the same expression in QlikSenseas well

paulyeo11
Valued Contributor II

Re: Simple KPI How to make % variance when +ve color change to Blue -ve RED ?

I am refer to KPI EXTENSION for qlik view

Sent from my iPhone