Law of total variance

var[Y]⏟total variance=E[var[Y|X]]⏟within groups variance+var[E[Y|X]]⏟between groups variance.

Where:

Proof: Wikipedia