Qlik Community

Qlik Sense App Development

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

madnanansari
New Contributor III

Custom color for the line graph

I have developed a line graph where I plot the Running Sales & Target for the month for each day. So as u progress the month; the chart shows an increasing sales vs target lines.

The formula for sales is as below:

RangeSum(Above(Sum(Sales)),0, RowNo(TOTAL)))

The graph was perfect.

The user comes with a requirement that he need to show sales with green color and the target with blue color. So I tried to develop the graph using value list. Value list dont bring the right graph. I observe that the RangeSum function in not working properly in the value list.

Any suggestions? Or there is any other way to color the line graph with two variables.

1 Solution

Accepted Solutions
MVP
MVP

Re: Custom color for the line graph

You can achieve this either with a calculated dimension as you tried to or with making a change to your data model and actually have a real dimension - which I think is a better data model anyway. I have enclosed your QVF updated with my changes and you can have a look at both solutions:

The first alternative based on your data model with two columns for the amounts:

2017-02-20 00_07_58-Qlik Sense Desktop.png

Measures Expression:

2017-02-20 00_11_40-Qlik Sense Desktop.png

Notice that you have to use the full ValueList('Sales','Target') which is the pseudo-name for the calculated dimension.

Furthermore since this ValueList() doubles the number of rows you have to make sure that you only pick every other row and that mandates a Mod()-function to check that we only pick half of the rows. It doesn't really matter is it is 1 or 0 we compare with...

Colors Custom Expression:

2017-02-20 00_12_57-Qlik Sense Desktop.png

The second alternative where there is a table that has been unpivoted in the load script by using the CrossTable prefix

2017-02-20 00_10_20-Qlik Sense Desktop.png

Measures Expression:

2017-02-20 00_11_19-Qlik Sense Desktop.png

Colors Custom Expression:

2017-02-20 00_16_16-Qlik Sense Desktop.png

5 Replies
MVP
MVP

Re: Custom color for the line graph

You can achieve this either with a calculated dimension as you tried to or with making a change to your data model and actually have a real dimension - which I think is a better data model anyway. I have enclosed your QVF updated with my changes and you can have a look at both solutions:

The first alternative based on your data model with two columns for the amounts:

2017-02-20 00_07_58-Qlik Sense Desktop.png

Measures Expression:

2017-02-20 00_11_40-Qlik Sense Desktop.png

Notice that you have to use the full ValueList('Sales','Target') which is the pseudo-name for the calculated dimension.

Furthermore since this ValueList() doubles the number of rows you have to make sure that you only pick every other row and that mandates a Mod()-function to check that we only pick half of the rows. It doesn't really matter is it is 1 or 0 we compare with...

Colors Custom Expression:

2017-02-20 00_12_57-Qlik Sense Desktop.png

The second alternative where there is a table that has been unpivoted in the load script by using the CrossTable prefix

2017-02-20 00_10_20-Qlik Sense Desktop.png

Measures Expression:

2017-02-20 00_11_19-Qlik Sense Desktop.png

Colors Custom Expression:

2017-02-20 00_16_16-Qlik Sense Desktop.png

madnanansari
New Contributor III

Re: Custom color for the line graph

Infact I have four columns to work on :

Sales,  Target, Sales Last Year Same Month, Sales vs Target

In this case how can I handle the Mod function?

MVP
MVP

Re: Custom color for the line graph

I don't understand what you mean by "Mod function" are you referring to Moduolo-function in expressions?

madnanansari
New Contributor III

Re: Custom color for the line graph

yes...

but thanks for your help. I have reached my target.

MVP
MVP

Re: Custom color for the line graph

You're welcome. Could you also please mark the question as answered too?