The Friedman two way ANOVA by ranks is a nonparametric test that can be used to compare three or more related groups. It works by ranking the data horizontally across rows, calculating the mean rank for each column, and comparing the column means. If the calculated test statistic is greater than the critical value, the null hypothesis that the groups are the same can be rejected. The document provides an example using biological oxygen demand data from 12 river sites to test if cleanup procedures affected BOD levels before, 1 month after, and 1 year after cleanup.