Finding the median from a date list dinamically

YuriHR

New Member
Joined
Apr 22, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hello :)

I'm having trouble with an apparent easy task, but I haven't found any reasonable solution.

In the column A are the dates, while in the column B are the values. For each day there's usually more than one value. I'm building a report with descriptive statistics, and it's working fine for the values, but I can't find a way to represent the median dynamically for the number of daily operations. For instance:

April 19: 8 rows; April 20: 4 rows; April 21: 5 rows; April 22: 3 rows ... In this case the median would be 4,5.

What I'd like to do is to find the median for the number of rows (operations) per day changing the date range dynamically, without using another column or sheet for help, only with formula.

(I tried a lot of array combinations with MEDIAN, IF, FREQUENCY and COUNTIF. Said formulas worked well for the values, but I really do not know what's going on with the dates.)

Thanks in advance!
 

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.
If your dates are chronological then I would suggest a formula on the basis of (this will definitely work)

=MEDIAN(INDEX(values range,MATCH(starting date, date range,0)):INDEX(values range,MATCH(ending date, date range,0)))

If the dates are not chronological then possibly an array confirmed formula like (this one might work, without testing I'm not certain that it is 100% correct).

=MEDIAN(IF(date range >= starting date,IF(date range <= ending date,values)))
 
Upvote 0
Thanks for your help, Jason!

Unfortunately, my problem is related to the median of the numbers of rows by day, though. For the values I used your last formula (ideally the dates would be chronological, but they're not) and had success.

in my first post, I mentioned the number of rows by day. Ideally, the formula would count the number of rows according to the range I'd choose, calculate the number of rows by day (from an array, I presume), and return the median of rows by day. It would be totally based on the column A.

Thanks again.
 
Upvote 0
Could you give a slightly bigger example, with the dates out of order and the results you need based on a couple of date ranges.
If you click the XL2BB button on the reply toolbar that will take you to an add-in that you can use to post a section of your sheet to the forum.
 
Upvote 0
is that what you want?

DateValueCountifDateMedian
19/04/20201119/04/20204.5
19/04/20202220/04/20202.5
19/04/20203321/04/20203
19/04/20204422/04/20202
19/04/202055
19/04/202066
19/04/202077
19/04/202088
20/04/202091
20/04/2020102
20/04/2020113
20/04/2020124
21/04/2020131
21/04/2020142
21/04/2020153
21/04/2020164
21/04/2020175
22/04/2020181
22/04/2020192
22/04/2020203
 
Upvote 0
Something like this:
Array formula that must be entered with CTRL-SHIFT-ENTER.

Book1
ABCD
14/19/2020
24/19/2020Median=4.5
34/19/2020
44/19/2020
54/19/2020
64/19/2020
74/19/2020
84/19/2020
94/20/2020
104/20/2020
114/20/2020
124/20/2020
134/21/2020
144/21/2020
154/21/2020
164/21/2020
174/21/2020
184/22/2020
194/22/2020
204/22/2020
Sheet2
Cell Formulas
RangeFormula
D2D2{=MEDIAN(IF(FREQUENCY(A1:A20,A1:A20)<>0,FREQUENCY(A1:A20,A1:A20)))}
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
Sandy and Jason, thanks for your help! AhoyNC just posted almost what I need, except for the range that needs to be inside the formula and linked with two cells (from/to).

I've tried a lot of combinations but most of them return #N/A (maybe an signal of a limitation of the array formula, I don't know).
 
Upvote 0
The proverbial penny has just dropped, I misunderstood what you were asking for, glad you got the answer that you need.
 
Upvote 0
Thank you for your time, Jason! And I'm sorry, my English is not so good, maybe it was my fault.

But AhoyNC's answer solves part of the problem. I still couldn't find the final formula :/
 
Upvote 0
If you turn your column A into a table then the formula will expand if you add dates.
If you want a start and end date then look at the formula in cell E8 below. The formula in E3 is for the whole data range in column A.

Book1
ABCDE
1Column1
24/19/2020
34/19/2020Median=3.5
44/19/2020
54/19/2020
64/19/2020Start4/19/2020
74/19/2020End Date4/22/2020
84/19/2020Median4.50
94/19/2020
104/20/2020
114/20/2020
124/20/2020
134/20/2020
144/21/2020
154/21/2020
164/21/2020
174/21/2020
184/21/2020
194/22/2020
204/22/2020
214/22/2020
224/23/2020
234/23/2020
244/25/2020
254/25/2020
Sheet2
Cell Formulas
RangeFormula
E3E3{=MEDIAN(IF(FREQUENCY(A2:A25,A2:A25)<>0,FREQUENCY(A2:A25,A2:A25)))}
E8E8{=MEDIAN(IF(FREQUENCY(IF($A$2:$A$25>=$E$6,IF($A$2:$A$25<=$E$7,$A$2:$A$25)),$A$2:$A$25)<>0,FREQUENCY(IF($A$2:$A$25>=$E$6,IF($A$2:$A$25<=$E$7,$A$2:$A$25)),$A$2:$A$25)))}
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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