The median of a dataset is the middle value when the observations are arranged in ascending order. It is the value below which 50% of the observations lie. For an odd number of observations, the median is the middle value. For an even number, the median is the average of the two middle values. The median can be calculated for both grouped and ungrouped data using different formulas depending on whether the data is grouped by value or range. Examples are provided to demonstrate calculating the median for different types of datasets.