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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Average new field on the Script

Hi,

I want to create a new field called "AvgPlace" by calculating the average of the values for the places. My data is like this:

Place   Store   Value

A          x          3

A          y          2

B          z          2

B          v          4

B          w         3

and I want a new table like this

Place    AvgPlace

A            2.5

B            3

I want to do it on the Script, but it just keeo telling me "Invalid Expression"

Labels (1)
1 Solution

Accepted Solutions
Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Try this

Data:

load * Inline [

Place ,  Store,   Value
A ,         x  ,        3
A ,         y,          2
B ,         z ,         2
B ,         v,          4
B,          w,         3
]
;


NoConcatenate
Data2:
LOAD
Place  //If you don't want the tables to join then rename this field
,Sum(Value) / Count(Place) AS AvgValue
Resident Data
Group BY
Place;

View solution in original post

4 Replies
swuehl
Champion III
Champion III

LOAD

     Place,

     avg( Value) as AvgPlace

RESIDENT YourTable

GROUP BY Place;

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

Try this

Data:

load * Inline [

Place ,  Store,   Value
A ,         x  ,        3
A ,         y,          2
B ,         z ,         2
B ,         v,          4
B,          w,         3
]
;


NoConcatenate
Data2:
LOAD
Place  //If you don't want the tables to join then rename this field
,Sum(Value) / Count(Place) AS AvgValue
Resident Data
Group BY
Place;

Not applicable
Author

You guys are amazing! Thank youu

Not applicable
Author

Thank youuuu