Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add the average line to a line chart with multiple lines

Hi - I'm trying to add an average line to my chart (attached).  I would like the average to be based on each of the score categories (000-100, 101-200, etc.).  For example, the average displayed for 000-100 should be the average of 19.2% and 18.4%, and the average displayed for 901-1000 should be the average of 15.9% and 15.2%.  I've spent quite a while on the forum and haven't been able to find a solution to this.  Any insight is greatly appreciated!

1 Solution

Accepted Solutions
MarcoWedel

Hi,

maybe this helps?

QlikCommunity_Thread_129247_Pic1.png

QlikCommunity_Thread_129247_Pic2.png

QlikCommunity_Thread_129247_Pic3.png

QlikCommunity_Thread_129247_Pic4.png

based on your sample data:

LOAD pet_proj_nm,

     unique_id,

     prospect_score_cat,

     resp_open_ind,

     cnt_tran

FROM [http://community.qlik.com/thread/129247]

(html, codepage is 1252, embedded labels, table is @1);

regards

Marco

View solution in original post

15 Replies
Not applicable
Author

Perhaps you could try:

avg(aggr(sum(Field1),Dim1))

Where Field1 is Prospect_Cat_Score and Dim1 is the field you want to aggregate over, Frozen Atlanta and Frozen New York.

Word of caution though, you cannot average averages, the result will be incorrect. You should be using the absolute values to recalculate the average.

Hope that helps.

Matt

Not applicable
Author

Hi Carey, were you able to solve this?

Best,

Matt

MarcoARaymundo
Creator III
Creator III

First: if you use the "UNIT (Frozen Atlanta)" like dimension, remove this.

Add expressions like this: Sum({<UNIT={'Frozen Atlanta'}>} VALUE) and named Frozen Atlanta. Repeat this to Fozen Brooklin.

For average add expression: AVG({<UNIT={'*'}>} VALUE)  and named average.

Not applicable
Author

Thank you guys for your suggestions.  The issue is, I don't want to hard code the expressions, since I'd like the user to be able to select the project names and then display the results accordingly.  I've attached a screenshot of the two dimensions and the expression I have so far.  The "pet_proj_nm" field corresponds to Frozen Atlanta etc, which should be dynamically selected.

QV Chart2.jpg

MarcoWedel

can you please post some sample data

thanks

regards

Marco

Not applicable
Author

Hi Carey,

If you attach some data I'm sure we'll solve this faster. In the meantime, let me make sure I understand what you need. You've got this expression:

sum(resp_open_ind)/sum(count_cst)


You want to calculate the overall average for each score category, right? To do this, you could try:


sum(total <prospect_score_cat > resp_open_ind)/sum(total<prospect_score_cat > count_cst)

The total <> will aggregate over prospect_score_cat while ignoring the categories. I think this will allow you to calculate the average.

Best,

Matt

Not applicable
Author

Thank you all.  Here are some sample data for two campaigns.

pet_proj_nmunique_idprospect_score_catresp_open_indcnt_tran
Frozen - AtlantaU_103089151801-90001
Frozen - AtlantaU_181230272901-100001
Frozen - AtlantaU_93147111901-100011
Frozen - AtlantaU_179205676701-80001
Frozen - AtlantaU_83974758801-90001
Frozen - AtlantaU_65797158901-100011
Frozen - AtlantaU_68806048801-90011
Frozen - AtlantaU_77061818801-90001
Frozen - AtlantaU_175996931901-100011
Frozen - AtlantaU_84699665801-90001
Frozen - AtlantaU_190622182901-100001
Frozen - AtlantaU_63637894801-90001
Frozen - AtlantaU_171898435801-90001
Frozen - AtlantaU_177005746801-90001
Frozen - AtlantaU_182376476901-100011
Frozen - AtlantaU_187151165901-100011
Frozen - AtlantaU_197030067101-20001
Frozen - AtlantaU_62110649701-80001
Frozen - AtlantaU_193029294801-90001
Frozen - AtlantaU_192368656701-80011
Frozen - AtlantaU_184599878701-80001
Frozen - AtlantaU_62796611901-100001
Frozen - AtlantaU_198194170501-60001
Frozen - AtlantaU_65645476801-90001
Frozen - AtlantaU_194627020801-90001
Frozen - AtlantaU_87018069801-90001
Frozen - AtlantaU_73016019701-80011
Frozen - AtlantaU_197628321801-90001
Frozen - BrooklynU_78854528701-80001
Frozen - BrooklynU_193333226901-100001
Frozen - BrooklynU_70315911901-100001
Frozen - BrooklynU_47777695701-80001
Frozen - BrooklynU_195260574901-100001
Frozen - BrooklynU_191148379901-100001
Frozen - BrooklynU_88431645801-90001
Frozen - BrooklynU_189185640801-90001
Frozen - BrooklynU_188648180801-90001
Frozen - BrooklynU_66749088901-100001
Frozen - BrooklynU_183496552901-100001
Frozen - BrooklynU_179399424801-90011
Frozen - BrooklynU_192366521701-80001
Frozen - BrooklynU_66962191801-90001
Frozen - BrooklynU_182515681801-90001
Frozen - BrooklynU_197041469901-100001
Frozen - BrooklynU_192882708901-100001
Frozen - BrooklynU_80302045801-90001
Frozen - BrooklynU_184120826701-80001
Frozen - BrooklynU_174324480301-40001
Frozen - BrooklynU_198382941701-80001
Frozen - BrooklynU_190374501901-100001


Matt - Your suggestion did give me the average (red line in the picture); however, after adding that expression, I no longer see a separate line for each of the two campaigns.  Instead, the blue line basically connects the value for the two campaigns within each score category.
Capture.JPG.jpg

Not applicable
Author

Hi Carey,

I can only get it to work if I specify Frozen Atlanta or Brooklyn in the expression, see attached. Looks like there may be a limitation to doing this if you use more than 1 dimension in the chart.

Hope that will work for you or perhaps someone else knows another way.

Matt

Not applicable
Author

Yeah, thanks Matt.  The second dimension seems to be the issue here, and unfortunately I can't remove that because we want to be dynamic based on the user's selection.

The alternative that I am using (for now) is to create a second chart that plots just the overall average, and overlay it on top - Definitely not desirable, but there does not appear to be another way.  Greatly appreciate it if anybody else has other suggestions!