To test this hypothesis, each group is divided into two subgroups: those whose scores fall at or below the median, and those whose scores are above it. The result is a two-way frequency table with two rows and g columns, where g is the number of categories in your grouping variable.

From this two-way frequency table, a chi-square statistic can be calculated to test the null hypothesis of row and column independence. In fact, the median test is a chi-square test of independence between group membership and the proportion of cases above and below the median.