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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating an average over a dimension

Hi everyone,

I've got a feeling that I'm missing something really obvious with this one.

Consider the following data:

SiteValue
A10
A20
A50
A60
A10
B100
B200
B500
B600
B100

What do I need to do in order to flag up values that are higher than the average value FOR THAT SITE?

I've tried IF(VALUE>AGGR(AVG(VALUE), SITE),1,0)  but that doesn't work and I've also tried using a variable, but that only works when 1 site is selected.

Ideally, I need to work this expression into my script, as opposed to a chart.

Many thanks in advance,

Robin

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like this:

INPUT:

LOAD Site,

     Value

FROM

[http://community.qlik.com/thread/65685?tstart=0]

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

AVG:

join LOAD Site, avg(Value) as Avg Resident INPUT Group by Site;

RESULT:

LOAD Site,

     Value,

//     Avg,

     if(Value>Avg,1,0) as Flag

    Resident INPUT;

   

drop table INPUT;

View solution in original post

2 Replies
swuehl
MVP
MVP

Maybe like this:

INPUT:

LOAD Site,

     Value

FROM

[http://community.qlik.com/thread/65685?tstart=0]

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

AVG:

join LOAD Site, avg(Value) as Avg Resident INPUT Group by Site;

RESULT:

LOAD Site,

     Value,

//     Avg,

     if(Value>Avg,1,0) as Flag

    Resident INPUT;

   

drop table INPUT;

Not applicable
Author

Superb - many thanks.