Skip to Content
0
Jul 21, 2022 at 03:02 PM

Creation of an weighted average - SAC

303 Views

Hey,

I try to calculate an average annual price (in my case - 2021) that is, sales divided by the quantity and put the result in the first month (in my case - January 2021)

In practice what I get is an average price calculation for each month separately, and in January the sum of all the results:

see below the code (data action) and result:

BY the way - if I do the same for the the counter only or for the nominator only - it works perfectly - the issue begin when I divide them

how can I do it (dividing by 12 gives of course a close but wrong result)

Thanks

Deb

MEMBERSET [d/Date]= %FROM_DATE% TO %TO_DATE%

VARIABLEMEMBER #TOTAL_INCOME_NET OF [d/ACCOUNT]
VARIABLEMEMBER #TOTAL_QTY_BTL OF [d/ACCOUNT]

DATA([d/ACCOUNT]=#TOTAL_INCOME_NET)=
RESULTLOOKUP([d/ACCOUNT]="ACT_INCOME_NET",[d/Version]="public.Actual")

DATA([d/ACCOUNT]=#TOTAL_QTY_BTL)=
RESULTLOOKUP([d/ACCOUNT]="SALES_QTY_BTL_ACT",[d/Version]="public.Actual")

DATA([d/ACCOUNT]="AVRG_YEARLY_PRICE",[d/Date]=FIRST())=
RESULTLOOKUP([d/ACCOUNT]=#TOTAL_INCOME_NET)/RESULTLOOKUP([d/ACCOUNT]=#TOTAL_QTY_BTL)


image.png

Attachments

image.png (46.1 kB)