Need a better formula

Ron99

Active Member
Joined
Feb 10, 2010
Messages
340
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have a set of consumption data, where I am trying to count by 2 months frequency and take an average. Since I have a data from 2012 till date my formula works fine but I am tired doing the loops. Below is the sample of data from what I am trying to achieve.


item
1-Jan
1-Feb
1-Mar
1-Apr
1-May
1-Jun
1-Jul
1-Aug
1-Sep
1-Oct
1-Nov
1-Dec
2 months
ABC
0
0
12
0
2
3
5
0
0
0
4
6
1.00

<tbody>
</tbody>

Formula under the 2months which I have =AVERAGE(COUNTIF(B2:C2,">0"),COUNTIF(C2:D2,">0"),COUNTIF(D2:E2,">0"),COUNTIF(E2:F2,">0"),COUNTIF(F2:G2,">0"),COUNTIF(G2:H2,">0"),COUNTIF(H2:I2,">0"),COUNTIF(I2:J2,">0"),COUNTIF(J2:K2,">0"),COUNTIF(K2:L2,">0"),COUNTIF(L2:M2,">0"))

I am looking for a better formula may be offset function.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try

=SUMPRODUCT((B2:L2>0)+(C2:M2>0))/COLUMNS(B2:L2)

or this array formula - entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}.

{=AVERAGE((B2:L2>0)+(C2:M2>0))}
 
Last edited:
Upvote 0
Thank you very much for the swift reply. It works the way I was expecting. Just a quick question, I would also like to do it for 3 months & 6 months frequency. Can you please assist.
 
Upvote 0
I have it figured out for 3 months & 6 months, but I am unable to understand how this function is working. If feasible can you please enlighten me. Thanks.
 
Upvote 0
Edit: Sorry, I hadn't seen your last post. Anyway, you can compare your solution to mine. :)

Thank you very much for the swift reply. It works the way I was expecting. Just a quick question, I would also like to do it for 3 months & 6 months frequency. Can you please assist.
Try these

Excel Workbook
ABCDEFGHIJKLMNOP
1item1-Jan1-Feb1-Mar1-Apr1-May1-Jun1-Jul1-Aug1-Sep1-Oct1-Nov1-Dec2 months3 months6 months
2ABC001202350004611.53.285714286
Average
 
Last edited:
Upvote 0
Thank you very much for your time. Have a great day!
 
Upvote 0

Forum statistics

Threads
1,215,635
Messages
6,125,945
Members
449,275
Latest member
jacob_mcbride

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
Back
Top