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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
madnanansari
Creator
Creator

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
petter
Partner - Champion III
Partner - Champion III

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

View solution in original post

5 Replies
petter
Partner - Champion III
Partner - Champion III

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
Creator
Creator
Author

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?

petter
Partner - Champion III
Partner - Champion III

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

madnanansari
Creator
Creator
Author

yes...

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

petter
Partner - Champion III
Partner - Champion III

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