Rolling 90 day average on filtered table

Eoughphily

New Member
Joined
Mar 1, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I'm trying to find the rolling last number of day average from a table of data with filtered cells. I originally had my formulas setup with raw data and not in a table format. The formulas worked beautifully until I changed it up and created tables from a master list of data for multiple types of queries. Once I did this I ran into hidden/filtered cells giving me inaccurate results. I have columns of dates and a column of numbers which are gathered from the difference between two dates. I'm looking for the average from the last any number of days. Here is the original formula I was using =AVERAGEIFS(C2:C21,A2:A21,">="&TODAY ()-90) where column C Has the data and column A has the dates. I believe I need to incorporate subtotal and offset into my formula to ignore hidden cells, but I can't seem to get it to work with the rolling average criteria. =SUBTOTAL (1, (IFS (A2:A21,C2:C21,">="&TODAY ()-90,OFFSET (H2:H21,0,-5)))) Is one of many variations i have tried but it just gives me the filtered average and night the rolling average. I know my columns are reversed on the second formula, when I put c first then a I get the average of dates which is a number the the thousands. I have spent all day searching Google to point me in the right direction but I cannot get it to work. Can somebody please assist? Thank you
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,667
Office Version
  1. 365
Platform
  1. Windows
It's never as simple as it sounds when you want to use conditions with filtered rows :eek:

See if this works, Array confirmed with Ctrl Shift Enter.

=AVERAGE(IF(SUBTOTAL(9,OFFSET(A2,ROW(A2:A21)-ROW(A2),0))=A2:A21,IF(A2:A21>=(TODAY()-90),C2:C21)))
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,861
Office Version
  1. 365
Platform
  1. Windows
Cross posted Averageif rolling average with filtered cells

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 

Eoughphily

New Member
Joined
Mar 1, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Yes I cross posted due to lack of reply from the other site. I really appreciate the reply. I will try this formula when I get home. Thank you again.

 

Eoughphily

New Member
Joined
Mar 1, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Hello @Fluff , That formula did not work with the ctrl shift enter array applied. I get #DIV/0! error.
Below are few formulas I have tried that have failed.

=AVERAGE(IF(C2:C21,A2:A21,">="&TODAY()-200),IF(SUBTOTAL(1,OFFSET(Q2,ROW(Q2:Q80)-ROW(Q2),0,1))>0,Q2:Q80)) RESULT - #DIV/0!
=AVERAGE(IFS(A:A=">="&TODAY()-120,IF(SUBTOTAL(101,OFFSET(e,ROW(C:C)-ROW(e),0,1))>0,C:C))) RESULT - #NAME?
=AVERAGE(IFS(C2:C21,A2:A21,">="&TODAY()-10,SUBTOTAL(1,OFFSET(H2:H21,0,-5)))) RESULT - 34.733 this is the correct average but isn't filtering rolling average
=AVERAGE(IFS(C2:C21,A2:A21,">="&TODAY()-10,SUBTOTAL(1,OFFSET(H2:H21,0,-5)))) - RESULT - 43765.73 this is average of dates in numerical form

The link to the other thread above has a posting of a sample excel file. It's not the best quality but has data to play with. I cannot seem to upload it onto this thread.


Thank you, for your time.
 

Eoughphily

New Member
Joined
Mar 1, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

There are when I change it to 200 days and I get the same error.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,667
Office Version
  1. 365
Platform
  1. Windows
With the file attached to your thread in the other forum, changing 90 to 200 gives me an average of 34.7333
 

Attachments

  • Annotation 2020-03-02 104250.png
    Annotation 2020-03-02 104250.png
    43.6 KB · Views: 1

Eoughphily

New Member
Joined
Mar 1, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
@jasonb75 @Fluff it does work. I didn't understand how it worked and changed the function for the subtotal from sum to average so it caused it to not work. Now I see why it works when it's set to sum. Do you know how I would alter that formula to count how many times the number of days is over a specified number like 20?
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,667
Office Version
  1. 365
Platform
  1. Windows
I didn't understand how it worked and changed the function ... so it caused it to not work.
Been there, done that, think I got away with it though, nobody realised🤫

Think this should work, but haven't tested it. Will need to be array confirmed as before with Ctrl Shift Enter.

=SUM(IF(SUBTOTAL(9,OFFSET(A2,ROW(A2:A21)-ROW(A2),0))=A2:A21,IF((A2:A21>=(TODAY()-90)),--(C2:C21>20))))
 

Watch MrExcel Video

Forum statistics

Threads
1,130,142
Messages
5,640,380
Members
417,139
Latest member
bdmprasenjit

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top