# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Rules, plus terms and conditions, can be found here.
Valued Contributor II

## SET expression how to change from Sum to Average ?

Hi All

I have the SET expression as below :-

sum({\$<year = {\$(=max(year))}, month = {"<=\$(=max({<year={\$(=max(year))}>} month))"}>} (STK_AMT)/1000)

it display Average stock amount  600 is wrong. I need it display average of Jan and Feb and Mar 2015 stock amount 600/3=200.

What i need it when i click on month = Jan , it will display  100

What i need it when i click on month = Feb , i want it will display 150

What i need it when i click on month = Mar , i want it will display 200

May i know how to modify the expression ?

Enclosed my QV Doc

Paul

1 Solution

Accepted Solutions
MVP

## Re: SET expression how to change from Sum to Average ?

Hey Paul,

I think it is doing it if you just change your expression to avg, instead of sum

=Avg({\$<year = {\$(=max(year))}, month = {"<=\$(=max({<year={\$(=max(year))}>} month))"}>} (STK_AMT)/1000)

Best,

Sunny

4 Replies
MVP

## Re: SET expression how to change from Sum to Average ?

Hey Paul,

I think it is doing it if you just change your expression to avg, instead of sum

=Avg({\$<year = {\$(=max(year))}, month = {"<=\$(=max({<year={\$(=max(year))}>} month))"}>} (STK_AMT)/1000)

Best,

Sunny

MVP

## Re: SET expression how to change from Sum to Average ?

Here is your applications also with that change (PFA)

HTH

Best,

Sunny

Valued Contributor II

## Re: SET expression how to change from Sum to Average ?

Hi sir

Thank you very much , it work fine now.

Paul

MVP

## Re: SET expression how to change from Sum to Average ?

Great, I am glad it worked for you.

Best,

Sunny