The Wolfram MathWorld page for "Semiprime" ($k=2$) at http://mathworld.wolfram.com/Semiprime.htmlhttps://mathworld.wolfram.com/Semiprime.html gives the following formula:
"A formula for the number of semiprimes less than or equal to $n$ is given by
$$\pi_2(x) = \sum_{k=1}^{\pi(\sqrt{x})} [\pi(x/p_k)-k+1],$$
where $\pi(x)$ is the prime counting function and $p_k$ is the $k$-th prime (R. G. Wilson V, pers. comm., Feb. 7, 2006; discovered independently by E. Noel and G. Panos around Jan. 2005, pers. comm., Jun. 13, 2006)."
Curiously, the number of terms in the above sum, $\pi(\sqrt{x})$, is approximately $\operatorname{Li}(\sqrt{x})$, which is the order of the main error term in the formula $\pi(x) = \operatorname{Li}(x) + e(x)$ itself. Further, the value of $\pi(x/p_k)$ in the final term is also equal to $\pi(x/\sqrt{x}) = \pi(\sqrt{x})$.
Here is a follow-up question: Has there been any research about the distribution of primes and semiprimes together? One would expect the error term to be smaller than for either primes or semiprimes alone, because a region with fewer primes will tend to have more semiprimes, and vice versa.