Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
francis_gr
Creator
Creator

how to include a average column in simple chart

Hi!

I need to add a new field in "average" chart (see the attached file) to calculate the avearge sales (sale_1, sale_2, sale_3) per year and job. I know that in excel it can be done with SUMIFS and COUNTIFS functions

I need this new field to calculate the percentage sales difference from the average sales

Regards

1 Solution

Accepted Solutions
jer_2011
Creator II
Creator II

hola,

La Buscas Expresión de Que es:

AGGR(NODISTINCT Avg(Sales_1),Job,Year) )

View solution in original post

10 Replies
JonnyPoole
Employee
Employee

sum( total <Year,Job> Sales_1+Sales_2+Sales_3)  / 3

salesperyearperjob.PNG.png

Not applicable

First, you have to add new field in the script layout , something unique. For example :  Worker&Job&Year as Key1.

Next you can create three different rows which will be equal on something like that:  sum(Sales_1)/Count(DISTINCT Key1);

  sum(Sales_2)/Count(DISTINCT Key1);

  sum(Sales_3)/Count(DISTINCT Key1);

And you’ll  have all averages values for each type of Sales; 

Regards,

Venelin

francis_gr
Creator
Creator
Author

Hi Venelin!

Thanks for your reply

I have follow your instruccions and put a new expresion in the chart (New) but i have the same value that in Average_S1,

I have attached the file so please correct me if i have something wrong.

In my response to Jonathan you can see (in excel table) the values that i'm looking for

Regards

francis_gr
Creator
Creator
Author

Hi Jonathan!

Thanks for your reply

May be i have not expressed well, but i'm not looking for the cumulative average of three sales. the resul thal i'm looking for is somethin like  that(i have done in excel)

Regards

WorkerYearJobSales_1Sales_2Sales_3avg_sale_1avg_sale_2avg_sale_3% deviation Sales_1% deviation Sales_2% deviation Sales_3
A0012011ABC143108153130,33136,00176,009,72%-25,93%-15,03%
A0022011ABC143113196130,33136,00176,009,72%-20,35%10,20%
A0032011DEF140189110132,50167,75152,505,66%11,24%-38,64%
A0042011DEF139105191132,50167,75152,504,91%-59,76%20,16%
A0052011GHI105109170119,67111,67166,67-12,26%-2,45%1,96%
A0062011GHI126117149119,67111,67166,675,29%4,56%-11,86%
A0072011ABC105187179130,33136,00176,00-19,44%27,27%1,68%
A0082011GHI128109181119,67111,67166,676,96%-2,45%7,92%
A0092011DEF141196123132,50167,75152,506,42%14,41%-23,98%
A0102011DEF110181186132,50167,75152,50-16,98%7,32%18,01%
A0012012ABC137193146129,67181,33157,335,66%6,04%-7,76%
A0022012ABC132155141129,67181,33157,331,80%-16,99%-11,58%
A0032012DEF100176199127,75163,75140,75-21,72%6,96%29,27%
A0042012DEF136154121127,75163,75140,756,46%-6,33%-16,32%
A0052012GHI100155196116,67134,00165,00-14,29%13,55%15,82%
A0062012GHI127147167116,67134,00165,008,86%8,84%1,20%
A0072012ABC120196185129,67181,33157,33-7,46%7,48%14,95%
A0082012GHI123100132116,67134,00165,005,43%-34,00%-25,00%
A0092012DEF133156102127,75163,75140,754,11%-4,97%-37,99%
A0102012DEF142169141127,75163,75140,7511,15%3,11%0,18%
A0012013ABC118115166114,33128,67150,333,21%-11,88%9,44%
A0022013ABC117118155114,33128,67150,332,33%-9,04%3,01%
A0032013DEF136143109123,50168,75133,5010,12%-18,01%-22,48%
A0042013DEF122188110123,50168,75133,50-1,21%10,24%-21,36%
A0052013GHI123141112117,33144,67150,004,83%-2,60%-33,93%
A0062013GHI112114158117,33144,67150,00-4,55%-26,90%5,06%
A0072013ABC108153130114,33128,67150,33-5,54%15,90%-15,64%
A0082013GHI117179180117,33144,67150,00-0,28%19,18%16,67%
A0092013DEF107197192123,50168,75133,50-13,36%14,34%30,47%
A0102013DEF129147123123,50168,75133,504,45%-14,80%-8,54%
JonnyPoole
Employee
Employee

Does this work for the 3 different average calcs ?


sum( total <Year,Job> Sales_1)  /  count(  distinct Year&Job)


sum( total <Year,Job> Sales_2) /  count(  distinct Year&Job)


sum( total <Year,Job> Sales_3) /  count(  distinct Year&Job)

francis_gr
Creator
Creator
Author

Hi!

No, it doesn't

with your expresion i have (Jonathan field). This value not match with my excel table.

Regards

qlick.jpg

jer_2011
Creator II
Creator II

hola,

La Buscas Expresión de Que es:

AGGR(NODISTINCT Avg(Sales_1),Job,Year) )

JonnyPoole
Employee
Employee

Ok. Can you share the actual  excel file ? The QVW seems like it has less data ...only has 1 row for each Year/Worker/Job combination so i couldn't test if the average is working.

francis_gr
Creator
Creator
Author

Hola Gerardo!!

Muchas gracias por tu respuesta. Funciona perfectamete.

Saludos.