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: 
Not applicable

Group By and Average at Script level

Hey,

i want to calculate the following scenario...

ID  Amount

1     10

1     10

1     10

2     20    

2     20

3     30

3     30

3     30

3     30

i want to group by id and calculate average of amount at script level.

Utsav

1 Solution

Accepted Solutions
er_mohit
Master II
Master II

hi try this

a:

LOAD * INLINE [

    id, amount

    1, 10

    1, 10

    1, 10

    2, 20

    2, 20

    3, 30

    3, 30

    3, 30

    3, 30

];

LOAD

Avg(amount)as avg_amount

Resident a

Group by id;

hope it helps

View solution in original post

4 Replies
Not applicable
Author

hi

try this

LOAD id,sum(amount) as sumamount,

     avg(amount) as avgamount

FROM

(ooxml, embedded labels, table is Sheet1) Group by id;

sujeetsingh
Master III
Master III

utsav u can do it in ui level very easily ....

Juast by takinmg your id as dimention ..

er_mohit
Master II
Master II

hi try this

a:

LOAD * INLINE [

    id, amount

    1, 10

    1, 10

    1, 10

    2, 20

    2, 20

    3, 30

    3, 30

    3, 30

    3, 30

];

LOAD

Avg(amount)as avg_amount

Resident a

Group by id;

hope it helps

khadeer
Specialist
Specialist

Aggr function works for that

aggr(avg(Amount),Id)