Let (X, ρ, µ) be a metric measure space of homogeneous type which supports a certain Poincaré inequality. Denote by the symbol C * c (X) the space of all continuous functions f with compact support satisfying that Lip ). In this article, the authors prove that, for anywith the positive equivalence constants independent of f , where V(x, y) := µ(B(x, ρ(x, y))). This generalizes a recent surprising formula of H. Brezis, J. Van Schaftingen, and P.-L. Yung from the n-dimensional Euclidean space R n to X. Applying this generalization, the authors establish new fractional Sobolev and Gagliardo-Nirenberg inequalities in X. All these results have a wide range of applications. Particularly, when applied to two concrete examples, namely, R n with weighted Lebesgue measure and the complete n-dimensional Riemannian manifold with non-negative Ricci curvature, all these results are new. The proofs of these results strongly depend on the geometrical relation of differences and derivatives in the metric measure space and the Poincaré inequality.