Calculating ratios and formulas