简体   繁体   中英

Calculate 3 month Average on the base of CustomerID

I am trying to calculate three month average sales in excel wrt customerid in excel. I tried by doing it by AverageIfs function but nothing helped.

A              B         C
Orderdate      sales    customerid
5/15/2019        7           1
5/15/2019        48.5        1
4/15/2019       92.94        1
3/17/2019     102.85         1
3/18/2019      49            1
3/18/2019     119.95         1
2/18/2019     58.96          1
1/20/2019      14.6         1
5/16/2019      17           6
4/15/2019     148.5         6
4/12/2019    912.94         6
3/17/2019   102.85          6
9/18/2018    22.34          6

Formula I tried: =AVERAGEIFS(B:B,C:C,C2)

output expected:

customerid      average(3 months)
1                    49.48         
6                   359.48

Let's start from today's date and the date 3 months ago (Make it dynamic):

Remember to change the cell format from General to Date. Otherwise, it will show [43563]

在此处输入图片说明

Next use the date as part of our filter:

在此处输入图片说明

在此处输入图片说明

Now you should get the most recent 3 months data:

在此处输入图片说明


Copy the filtered data into a new spreadsheet

Copy the filtered data into a new spreadsheet

Copy the filtered data into a new spreadsheet


Next Step: get the distinct customer ID: 在此处输入图片说明 在此处输入图片说明

You will get this:

在此处输入图片说明

Last Step:

Use the function "AVERAGEIF":

在此处输入图片说明

Done!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM