SOLVED

Pivot table, get Average by Total Numbers of months

%3CLINGO-SUB%20id%3D%22lingo-sub-1859755%22%20slang%3D%22en-US%22%3EPivot%20table%2C%20get%20Average%20by%20Total%20Numbers%20of%20months%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1859755%22%20slang%3D%22en-US%22%3EI%20have%20an%20excel%20data%20table%20which%20have%20these%20colomns%2C%20Purchae%20date%2C%20Item%20name%2C%20Quantity%2C%20Supplier%20name%2C%20Now%20i%20want%20to%20get%20average%20of%20quantity%20by%20total%20number%20of%20months.%20I.e%20quanty%20sum%20is%2050%20and%20this%20is%20tenth%20month.%20So%20the%20average%20should%20be%205%20per%20month.%20More%20over%20this%20should%20keep%20updating%20as%20the%20month%20number%20go%20on.%20Best%20regards%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1859755%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1859776%22%20slang%3D%22en-US%22%3ERe%3A%20Pivot%20table%2C%20get%20Average%20by%20Total%20Numbers%20of%20months%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1859776%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F782935%22%20target%3D%22_blank%22%3E%40ndmalam%3C%2FA%3E%26nbsp%3BI%20suppose%20you%20have%20the%20current%20date%20somewhere%20in%20your%20sheet.%20If%20not%2C%20enter%20it%20somewhere%2C%20for%20instance%20in%20A1%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DTODAY()%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3BThen%2C%20in%20another%20cell%20(say%20A2)%20enter%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DMONTH(A1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EThis%20will%20give%20you%20the%20current%20number%20of%20the%20month.%3C%2FP%3E%3CP%3EThen%20you%20can%20take%20the%20sum%20of%20quantities%20and%20divide%20it%20be%20the%20number%20in%20A2%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%3CTOTAL%20qty%3D%22%22%3E%2FA2%3C%2FTOTAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3Bwhere%20%3CTOTAL%20qty%3D%22%22%3E%20refers%20to%20a%20SUM%20range%20for%20the%20total%20quantity%20or%20a%20cell%20where%20the%20total%20quantity%20already%20resides.%3C%2FTOTAL%3E%3C%2FP%3E%3CP%3EI%20have%20attached%20a%20very%20basis%20example%2C%20using%20a%20structured%20table%20in%20the%20attached%20file.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1861350%22%20slang%3D%22en-US%22%3ERe%3A%20Pivot%20table%2C%20get%20Average%20by%20Total%20Numbers%20of%20months%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1861350%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3Bplease%20have%20a%20look%20at%20the%20attached%20file.%26nbsp%3B%3C%2FP%3E%3CP%3Ethe%20problem%20is%20when%20i%20use%20average%20function%20it%20averages%20only%20counted%20number%20of%20month%20in%20which%20i%20made%20purchase.%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20i%20want%20the%20average%20of%20total%20months%20that%20is%2011%20Months%20by%20now.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1862104%22%20slang%3D%22en-US%22%3ERe%3A%20Pivot%20table%2C%20get%20Average%20by%20Total%20Numbers%20of%20months%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1862104%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F782935%22%20target%3D%22_blank%22%3E%40ndmalam%3C%2FA%3E%26nbsp%3BPerhaps%20like%20in%20the%20attached%3F%20Otherwise%20I%20don't%20undertand%20what%20you%20ask%20for.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor
I have an excel data table which have these colomns, Purchae date, Item name, Quantity, Supplier name, Now i want to get average of quantity by total number of months. I.e quanty sum is 50 and this is tenth month. So the average should be 5 per month. More over this should keep updating as the month number go on. Best regards
4 Replies

@ndmalam I suppose you have the current date somewhere in your sheet. If not, enter it somewhere, for instance in A1:

=TODAY()

 Then, in another cell (say A2) enter:

=MONTH(A1)

This will give you the current number of the month.

Then you can take the sum of quantities and divide it be the number in A2

=<total qty>/A2

 where <total qty> refers to a SUM range for the total quantity or a cell where the total quantity already resides.

I have attached a very basis example, using a structured table in the attached file.

@Riny_van_Eekelen please have a look at the attached file. 

the problem is when i use average function it averages only counted number of month in which i made purchase. 

But i want the average of total months that is 11 Months by now.

@ndmalam Perhaps like in the attached? Otherwise I don't undertand what you ask for.

Best Response confirmed by ndmalam (Occasional Contributor)
Solution

@ndmalam 

Formula solution could work, but only if PivotTable is static, i.e. not sorted, not filtered and range is not updated.

 

Add both SUM() and AVERAGE() aggregations in Grand Total without having the same for each month. Some columns could be hided, but from my point of view that's not reliable solution.

 

I'd suggest to change layout a bit. First, creating PivotTable add data to data model, with that add measure as

Average Qty:=VAR
    monthsSelected=
       CALCULATE(
           DISTINCTCOUNT(
              Range[Purchasedate (Month)] ),
              ALLEXCEPT(Range, Range[Purchasedate (Month)]
           )
       )
RETURN  DIVIDE(SUM(Range[Quantity]), monthsSelected)

For PivotTable move Values to Rows pane

image.png

with that layout will be as

image.png

That gives extra rows, perhaps that's better than extra columns.

 

As for number of months, we could take one for TODAY(), but with that we will have wrong average with filtering of months. For example, if we select only third quarter, we will have correct average with above formula

image.png

Please check the last sheet in attached