The law of total variance says that if $X,Y$ are real-valued random variables and $\operatorname E(X^2)<+\infty,$ then
$$
\operatorname{var}(X) = \overbrace{\operatorname{var}(\operatorname E(X\mid Y))}^{\begin{smallmatrix} \text{explained} \\ \text{component} \\ \text{of the variance} \end{smallmatrix}} {} + {} \overbrace{ \operatorname E(\operatorname{var}(X\mid Y)) }^{\begin{smallmatrix} \text{unexplained} \\ \text{component} \\ \text{of the variance} \end{smallmatrix}}
$$
A more concrete version is that in the analysis of variance, the sum of squares of residuals ("residuals" are not to be confused with "errors") plus the sum of squares due to regression equals the total corrected sum of squares (that last being the sum of squares of deviations from the sample mean).
Most statistics texts tell you that the proportion of the total variance that is "explained" is the square of the correlation between $X$ and $Y.$ (For that you need to assume $Y$ also has a finite second moment. But the validity of the identity above does not depend on $Y$ being real-valued at all, and in cases where $Y$ takes values in a set with no structure or in $\mathbb R^n$ or something else, it is still standard to call the explained proportion of the total variance $\text{“}R^2\text{”},$ even though in such cases there is no quantity called $R.$) Some textbooks go on to say that that is also the square of the cosine of an angle (one of the angles of the right triangle that is involved), and then deduce certain bounds on the correlation between $X$ and $Z$ given those between $X$ and $Y$ and between $Y$ and $Z.$
A further generalization is Brillinger's law of total cumulance, of which the following is the case $n=4{:}$
\begin{align}
\text{joint cumulant} = {} & \kappa(X_1,X_2,X_3,X_4) \\[8pt]
= {} & \kappa(\kappa(X_1,X_2,X_3,X_4\mid Y)) \\[6pt]
& {} + {} \underbrace{ \kappa(\kappa(X_1,X_2,X_3\mid Y), \kappa(X_4\mid Y)) + \cdots}_\text{4 terms} \\[2pt]
& {} + {} \underbrace{ \kappa(\kappa(X_1,X_2\mid Y),\kappa(X_3,X_4\mid Y)) + \cdots }_\text{3 terms} \\[6pt]
& {} + {} \underbrace{\kappa(\kappa(X_1,X_2\mid Y),\kappa(X_3\mid Y), \kappa(X_4\mid Y)) + \cdots}_\text{6 terms} \\[6pt]
& {} + \kappa(\kappa(X_1\mid Y),\kappa(X_2\mid Y), \kappa(X_3\mid Y), \kappa(X_4\mid Y))
\end{align}
where the sum is over the set of all partitions of the set $\{X_1,\ldots,X_n\}$ of random variables.