18 Replies Latest reply: Jun 21, 2018 8:16 AM by omar bensalem

# Expression for colour by measure

Hi Guys,

I have 3 different measures representing my data and I am looking am looking for an expression to add different colors to my bar chart through an expression. Any help would be appreciated.

I have sales data from 2015-2018 and wanted to add growth rates over the years as a KPI. How can this be achieved through an expression? Please advice.

Regards,

Rony

• ###### Re: Expression for colour by measure

can you provide sample qvf??

Regards,

• ###### Re: Expression for colour by measure

Max,

I have started a new discussion with the same subject line and have added a sample qvf there. I am not getting the advanced editor option while replying to you here.

Thanks,

Rony

• ###### Re: Expression for colour by measure

Go to the expression tab, click on the desired measure. There will be a '+' icon. Click Background Color and and give a desired RGB() Function.

You can also give basic colors as Function like Red() ,Green(), Black().

• ###### Re: Expression for colour by measure

or if you are looking to change the color based on value like red for low, yellow for normal and green for high. you can give if conditions in the same Background color expression box

• ###### Re: Expression for colour by measure

Hi,

to give the colour by measure you will have to add the expression in the master item.

• ###### Re: Expression for colour by measure

Hi Vishweshwari,

How do we do that?

• ###### Re: Expression for colour by measure

hi,

In the left hand side there is a master item you have to create a master measure with the expression which u have and give the colour according to your requirement

• ###### Re: Expression for colour by measure

Thank you Vishweshwari!

• ###### Re: Expression for colour by measure

hi

if you find the solution then close the thread .

• ###### Re: Expression for colour by measure

Vishweshwari,

One more question. I have sales data from 2015-2018 and wanted to add growth rates over the years as a KPI. How can this be achieved through an expression?

Regards,

Rony

• ###### Re: Expression for colour by measure

As a Measure (format it as %)

(sum({<Year={"\$(=max(Year))"}>}YourMeasure)

-

sum({<Year={"\$(=max(Year)-1)"}>}YourMeasure))

/

sum({<Year={"\$(=max(Year)-1)"}>}YourMeasure)

As a label:

='Growth from '&(max(Year)-1)&' to '&(max(Year))

With that when you select 2017 for example; u'll have the growth from 2016 to 2017 and so on.

• ###### Re: Expression for colour by measure

Omar,

Will the above formula work only for 2 years or more? I have data from 2015-2018.

Regards,

Rony

• ###### Re: Expression for colour by measure

What do u mean?

In ur KPI object, what do you want to have?

Exactly?

• ###### Re: Expression for colour by measure

I want the kpi to show growth rate for 2016 over 2015, 2017 over 2016, 2018 over 2017 as and when the selections are applied.

• ###### Re: Expression for colour by measure

this is 3 separate measures; u can't have all 3 of them in the KPI object.

use a bar/line/combined chart; as a dimension: Year

as a measure;the measure I've already given you.

try it and see what happens

• ###### Re: Expression for colour by measure

OKay. Thanks Omar.

• ###### Re: Expression for colour by measure

Hi Omar,

Which one should I be taking here?

Rony

• ###### Re: Expression for colour by measure

u're talking of this?

(sum({<Year={"\$(=max(Year))"}>}YourMeasure)

-

sum({<Year={"\$(=max(Year)-1)"}>}YourMeasure))

/

sum({<Year={"\$(=max(Year)-1)"}>}YourMeasure)

As a label:

='Growth from '&(max(Year)-1)&' to '&(max(Year))