Because this is essentially a duplicate, I address a few issues that are do not explicitly overlap the related question or answer:

If a class has cumulative frequency .5, then the median is at the boundary of that class and the next larger one.

If is large (really the only case where this method is generally successful), there is little difference between and in the formula. All references I checked use .

Before computers were widely available, large datasets were customarily reduced to categories (classes) and plotted as histograms. Then the histograms were used to approximate the mean, variance, median, and other descriptive measures. Nowadays, it is best just to use a statistical computer package to find exact values of all measures.

One remaining application is to try to re-claim the descriptive measures from grouped data or from a histogram published in a journal. These are cases in which the original data are no longer available.

This procedure to approximate the sample median from grouped data $assumes$ that data are distributed in roughly a uniform fashion throughout the median interval. Then it uses interpolation to approximate the median. (By contrast, methods to approximate the sample mean and sample variance from grouped data one assumes that all obseervations are concentrated at their class midpoints.)

Answer from BruceET on Stack Exchange
๐ŸŒ
BYJUS
byjus.com โ€บ maths โ€บ median-of-grouped-data
Median of Grouped Data
... The formula to find the median of grouped data is: Median = l+ [((n/2) โ€“ cf)/f] ร— h Where l = lower limit of median class, n = number of observations, h = class size, f = frequency of median class, cf = cumulative frequency of class preceding ...
Published ย  June 16, 2022
Views ย  34K
People also ask

What is the formula to find the median of grouped data?
The formula to find the median of grouped data is: ยท Median = l+ [((n/2) โ€“ cf)/f] ร— h ยท Where l = lower limit of median class, n = number of observations, h = class size, f = frequency of median class, cf = cumulative frequency of class preceding the median class.
๐ŸŒ
byjus.com
byjus.com โ€บ maths โ€บ median-of-grouped-data
Median of Grouped Data
How to find the median value if the number of observations is odd?
If the number of observations (n) is odd, the median is the (n+1)/2th observation.
๐ŸŒ
byjus.com
byjus.com โ€บ maths โ€บ median-of-grouped-data
Median of Grouped Data
How to find the median value if the number of observations is even?
If the number of observations (n) is even, the median is the average of n/2th and (n/2)+1th observation.
๐ŸŒ
byjus.com
byjus.com โ€บ maths โ€บ median-of-grouped-data
Median of Grouped Data
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ mathematics โ€บ median-of-grouped-data
Median of Grouped Data: Formula, How to Find, and Solved Examples - GeeksforGeeks
July 23, 2025 - The lower limit (l) and frequency (f) of the median class are 20 and 12 respectively. And, the cumulative frequency (cf) of class preceding the median class is 12. Now, we can substitute these values in the formula to calculate value of median, ... Thus, the value of median corresponding to the given grouped data comes out to be 26.67.
๐ŸŒ
AtoZmath
atozmath.com โ€บ StatsG.aspx
Mean, Median and Mode for grouped data calculator
Find Mean, Median and Mode for grouped data calculator - Find Mean, Median and Mode for grouped data, step-by-step online
๐ŸŒ
Cuemath
cuemath.com โ€บ data โ€บ median-of-grouped-data
Median of Grouped Data - Formula, Class 10, How to Find?
Therefore, to find the median for grouped data we can use the following steps and formula: Step 1: Find the total number of observations. Step 2: Define the class size, and divide the data into different classes.
Top answer
1 of 3
2

Because this is essentially a duplicate, I address a few issues that are do not explicitly overlap the related question or answer:

If a class has cumulative frequency .5, then the median is at the boundary of that class and the next larger one.

If is large (really the only case where this method is generally successful), there is little difference between and in the formula. All references I checked use .

Before computers were widely available, large datasets were customarily reduced to categories (classes) and plotted as histograms. Then the histograms were used to approximate the mean, variance, median, and other descriptive measures. Nowadays, it is best just to use a statistical computer package to find exact values of all measures.

One remaining application is to try to re-claim the descriptive measures from grouped data or from a histogram published in a journal. These are cases in which the original data are no longer available.

This procedure to approximate the sample median from grouped data $assumes$ that data are distributed in roughly a uniform fashion throughout the median interval. Then it uses interpolation to approximate the median. (By contrast, methods to approximate the sample mean and sample variance from grouped data one assumes that all obseervations are concentrated at their class midpoints.)

2 of 3
0

According to what I learned the class where the median is located is the lowest class for which the cumulative frequency equals or exceeds

Therefore, the median class would be in 30-40. which would give 30.833 approximately as you said 31.

๐ŸŒ
Microsoft Support
support.microsoft.com โ€บ en-us โ€บ office โ€บ calculate-the-median-of-a-group-of-numbers-2e3ec1aa-5046-4b4b-bfc4-4266ecf39bf9
Calculate the median of a group of numbers - Microsoft Support
In the Formula Builder pane, type MEDIAN in the Search box, and then select Insert Function. Make sure the cell span in the Number1 box matches your data (In this case, A1:A7). For this example, the answer that appears in the cell should be 8. Tip: To switch between viewing the results and ...
Find elsewhere
๐ŸŒ
Statology
statology.org โ€บ home โ€บ how to find the median of grouped data (with examples)
How to Find the Median of Grouped Data (With Examples)
February 11, 2022 - This tutorial explains how to calculate the median value of grouped data, including several examples.
๐ŸŒ
Reddit
reddit.com โ€บ r/excel โ€บ is there a single formula for calculating median of grouped data for multiple datasets ?
r/excel on Reddit: Is there a single formula for Calculating Median of Grouped Data for multiple datasets ?
August 11, 2022 -

Each row is a separate dataset (up to 150 rows in a spreadsheet). The columns give the frequency in each group. I can manually find the median class and calculate the median for each row (albeit with some difficulty). But would like to make it a more automatic procedure.

I hope the screen shot below helps.

Top answer
1 of 6
1
u/AussieRuth - Your post was submitted successfully. Once your problem is solved, reply to the answer(s) saying Solution Verified to close the thread. Follow the submission rules -- particularly 1 and 2. To fix the body, click edit. To fix your title, delete and re-post. Include your Excel version and all other relevant information Failing to follow these steps may result in your post being removed without warning. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2 of 6
1
With grouped data, you have the x-value and its frequency, eg if the data are: 0 0 1 2 3 3 4 4 4 , you could write it as x 0 1 2 3 4 f 2 1 1 2 3 The median is found by finding the half-way point ie the 5th point, ie x=3. If the frequencies are fairly large eg in the 100s, then you cumulatively add until you get to half-way. If, instead of simple x- values, you have say age-ranges or income-brackets, then you can only find the median class (bracket) this way. There is a further adjustment to get an actual numerical estimate of the median. My median brackets are different for each row, so the xl formulae for the adjustment is different for each row. And I have to physically change the formula for each row. That's what I would like to do automatically. eg in row 17, the formulae use columns W and X to calculate median in row 18, the formulae use columns U and V to calculate median Not sure if this is what you wanted to know about need to automate.
๐ŸŒ
YouTube
youtube.com โ€บ watch
How To Calculate the Median of Grouped Data - Statistics
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
๐ŸŒ
University of Massachusetts
people.umass.edu โ€บ biep540w โ€บ pdf โ€บ Grouped Data Calculation.pdf pdf
1. Mean, Median and Mode 2. First Quantile, third Quantile and Interquantile
Calculate the mean. Solution: X is the midpoint of the ยท class. It is adding the class ยท limits and divide by 2. Median and Interquartile ยท Range ยท โ€“ Grouped Data ยท Step 1: Construct the cumulative frequency distribution. Step 2: Decide the class that contain the median.
๐ŸŒ
ALLEN
allen.in โ€บ home โ€บ jee maths โ€บ median of grouped data
Median of Grouped Data with Solved Examples
May 19, 2025 - To find the median of grouped data, use the following formula: ... Create a cumulative frequency column from the frequency distribution. Calculate N/2, where N is the total frequency.
๐ŸŒ
Math is Fun
mathsisfun.com โ€บ data โ€บ frequency-grouped-mean-median-mode.html
Mean, Median and Mode from Grouped Frequencies
59, 65, 61, 62, 53, 55, 60, 70, ... 59 + 68 + 61 + 6721 Mean = 61.38095... To find the Median Alex places the numbers in value order and finds the middle number....
๐ŸŒ
Slideshare
slideshare.net โ€บ home โ€บ education โ€บ median of grouped data
Median of grouped data | PPTX
This document provides steps for ... frequencies, and cumulative frequencies. 2. Find the median class by calculating N/2, where N is the total number of data points....
๐ŸŒ
Testbook
testbook.com โ€บ home โ€บ maths โ€บ median of grouped data
How to Find the Median of Grouped Data with Step-by-Step Solved Examples
Learn how to calculate the median of grouped data using a simple formula and clear steps. Includes easy-to-follow solved examples for better understanding.
๐ŸŒ
The Bricks
thebricks.com โ€บ resources โ€บ how-to-find-median-in-excel-for-grouped-data
How to Find the Median in Excel for Grouped Data
To identify the median class interval, you need to know the total number of observations in your dataset. This is simply the sum of all frequencies, which you can calculate using the SUM function in Excel:
๐ŸŒ
Online Math 4 All
onlinemath4all.com โ€บ finding-median-for-grouped-data.html
Finding Median for Grouped Data
Calculate the median. ... Substitute. ... The following table gives the weekly expenditure of 200 families. Find the median of the weekly expenditure. ... Substitute. ... The Median of the following data is 24. Find the value of x. ... Since the median is 24 and median class is 20 โ€“ 30. ... Substitute. ... The table below gives data on the heights in cm, of 51 children. ... To get 26th value, we need to get 4th value.
Top answer
1 of 6
7

Since you already know the formula, it should be easy enough to create a function to do the calculation for you.

Here, I've created a basic function to get you started. The function takes four arguments:

  • frequencies: A vector of frequencies ("number" in your first example)
  • intervals: A 2-row matrix with the same number of columns as the length of frequencies, with the first row being the lower class boundary, and the second row being the upper class boundary. Alternatively, "intervals" may be a column in your data.frame, and you may specify sep (and possibly, trim) to have the function automatically create the required matrix for you.
  • sep: The separator character in your "intervals" column in your data.frame.
  • trim: A regular expression of characters that need to be removed before trying to coerce to a numeric matrix. One pattern is built into the function: trim = "cut". This sets the regular expression pattern to remove (, ), [, and ] from the input.

Here's the function (with comments showing how I used your instructions to put it together):

GroupedMedian <- function(frequencies, intervals, sep = NULL, trim = NULL) {
  # If "sep" is specified, the function will try to create the 
  #   required "intervals" matrix. "trim" removes any unwanted 
  #   characters before attempting to convert the ranges to numeric.
  if (!is.null(sep)) {
    if (is.null(trim)) pattern <- ""
    else if (trim == "cut") pattern <- "\\[|\\]|\\(|\\)"
    else pattern <- trim
    intervals <- sapply(strsplit(gsub(pattern, "", intervals), sep), as.numeric)
  }

  Midpoints <- rowMeans(intervals)
  cf <- cumsum(frequencies)
  Midrow <- findInterval(max(cf)/2, cf) + 1
  L <- intervals[1, Midrow]      # lower class boundary of median class
  h <- diff(intervals[, Midrow]) # size of median class
  f <- frequencies[Midrow]       # frequency of median class
  cf2 <- cf[Midrow - 1]          # cumulative frequency class before median class
  n_2 <- max(cf)/2               # total observations divided by 2

  unname(L + (n_2 - cf2)/f * h)
}

Here's a sample data.frame to work with:

mydf <- structure(list(salary = c("1500-1600", "1600-1700", "1700-1800", 
    "1800-1900", "1900-2000", "2000-2100", "2100-2200", "2200-2300", 
    "2300-2400", "2400-2500"), number = c(110L, 180L, 320L, 460L, 
    850L, 250L, 130L, 70L, 20L, 10L)), .Names = c("salary", "number"), 
    class = "data.frame", row.names = c(NA, -10L))
mydf
#       salary number
# 1  1500-1600    110
# 2  1600-1700    180
# 3  1700-1800    320
# 4  1800-1900    460
# 5  1900-2000    850
# 6  2000-2100    250
# 7  2100-2200    130
# 8  2200-2300     70
# 9  2300-2400     20
# 10 2400-2500     10

Now, we can simply do:

GroupedMedian(mydf$number, mydf$salary, sep = "-")
# [1] 1915.294

Here's an example of the function in action on some made up data:

set.seed(1)
x <- sample(100, 100, replace = TRUE)
y <- data.frame(table(cut(x, 10)))
y
#           Var1 Freq
# 1   (1.9,11.7]    8
# 2  (11.7,21.5]    8
# 3  (21.5,31.4]    8
# 4  (31.4,41.2]   15
# 5    (41.2,51]   13
# 6    (51,60.8]    5
# 7  (60.8,70.6]   11
# 8  (70.6,80.5]   15
# 9  (80.5,90.3]   11
# 10  (90.3,100]    6

### Here's GroupedMedian's output on the grouped data.frame...
GroupedMedian(y$Freq, y$Var1, sep = ",", trim = "cut")
# [1] 49.49231

### ... and the output of median on the original vector
median(x)
# [1] 49.5

By the way, with the sample data that you provided, where I think there was a mistake in one of your ranges (all were separated by dashes except one, which was separated by a comma), since strsplit uses a regular expression by default to split on, you can use the function like this:

x<-c(110,180,320,460,850,250,130,70,20,10)
colnames<-c("numbers")
rownames<-c("[1500-1600]","(1600-1700]","(1700-1800]","(1800-1900]",
            "(1900-2000]"," (2000,2100]","(2100-2200]","(2200-2300]",
            "(2300-2400]","(2400-2500]")
y<-matrix(x,nrow=length(x),dimnames=list(rownames,colnames))
GroupedMedian(y[, "numbers"], rownames(y), sep="-|,", trim="cut")
# [1] 1915.294
2 of 6
4

I've written it like this to clearly explain how it's being worked out. A more compact version is appended.

library(data.table)

#constructing the dataset with the salary range split into low and high
salarydata <- data.table(
  salaries_low = 100*c(15:24),
  salaries_high = 100*c(16:25),
  numbers = c(110,180,320,460,850,250,130,70,20,10)
)

#calculating cumulative number of observations
salarydata <- salarydata[,cumnumbers := cumsum(numbers)]
salarydata
   # salaries_low salaries_high numbers cumnumbers
   # 1:         1500          1600     110        110
   # 2:         1600          1700     180        290
   # 3:         1700          1800     320        610
   # 4:         1800          1900     460       1070
   # 5:         1900          2000     850       1920
   # 6:         2000          2100     250       2170
   # 7:         2100          2200     130       2300
   # 8:         2200          2300      70       2370
   # 9:         2300          2400      20       2390
   # 10:         2400          2500      10       2400

#identifying median group
mediangroup <- salarydata[
  (cumnumbers - numbers) <= (max(cumnumbers)/2) & 
  cumnumbers >= (max(cumnumbers)/2)]
mediangroup
   # salaries_low salaries_high numbers cumnumbers
   # 1:         1900          2000     850       1920

#creating the variables needed to calculate median
mediangroup[,l := salaries_low]
mediangroup[,h := salaries_high - salaries_low]
mediangroup[,f := numbers]
mediangroup[,c := cumnumbers- numbers]
n = salarydata[,sum(numbers)]

#calculating median
median <- mediangroup[,l + ((h/f)*((n/2)-c))]
median
   # [1] 1915.294

The compact version -

EDIT: Changed to a function at @AnandaMahto's suggestion. Also, using more general variable names.

library(data.table)

#Creating function

CalculateMedian <- function(
   LowerBound,
   UpperBound,
   Obs
)
{
   #calculating cumulative number of observations and n
   dataset <- data.table(UpperBound, LowerBound, Obs)

   dataset <- dataset[,cumObs := cumsum(Obs)]
   n = dataset[,max(cumObs)]

   #identifying mediangroup and dynamically calculating l,h,f,c. We already have n.
   median <- dataset[
      (cumObs - Obs) <= (max(cumObs)/2) & 
      cumObs >= (max(cumObs)/2),

      LowerBound + ((UpperBound - LowerBound)/Obs) * ((n/2) - (cumObs- Obs))
   ]

   return(median)
}


# Using function
CalculateMedian(
  LowerBound = 100*c(15:24),
  UpperBound = 100*c(16:25),
  Obs = c(110,180,320,460,850,250,130,70,20,10)
)
# [1] 1915.294
๐ŸŒ
AtoZMath
atozmath.com โ€บ example โ€บ StatsG.aspx
Median Example for grouped data
Median Example for grouped data - Median Example for grouped data, step by step online
๐ŸŒ
The Math Doctors
themathdoctors.org โ€บ finding-the-median-of-grouped-data
Finding the Median of Grouped Data โ€“ The Math Doctors
Median data entry = (22 + 1)/2 ... 80 to 90 (10 class width): 81.667, 83.333, 85, 86.667, 88.333, 90 I used these in the formula Median = L + {(n + 1)/2) - c.f.} * (h/f) Here, L = lower limit of median class h = class width c.f....