What is the formula used for calculating factors relative to Industry?

Since ranking systems do not yet support ranking a factor relative to it’s SubIndustry, I am trying to construct something manually by subtracting the SubIndustry median. Something like this: "EarnYield - FMedian(“EarnYield”, #SubIndustry). This is not getting the results that I am looking for.

To verify this, the results of ranking a factor vs. Industry is different from ranking a factor minus it’s industry median.

What is the formula used for calculating factors relative to Industry?