Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
ronman10
Creator
Creator

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

18 Replies
vishweshwarisun
Partner - Creator
Partner - Creator

hi

if you find the solution then close the thread .

OmarBenSalem
Partner - Champion II
Partner - Champion II

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.


ronman10
Creator
Creator
Author

Omar,

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

Regards,

Rony

OmarBenSalem
Partner - Champion II
Partner - Champion II

What do u mean?

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

Exactly?

ronman10
Creator
Creator
Author

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.

OmarBenSalem
Partner - Champion II
Partner - Champion II

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

Instead;

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

ronman10
Creator
Creator
Author

OKay. Thanks Omar.

ronman10
Creator
Creator
Author

Hi Omar,

Which one should I be taking here?

Rony

OmarBenSalem
Partner - Champion II
Partner - Champion II

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