How can you determine the distance of a star using the magnitude equation?
This is all absolutely true (pun intended). Finding absolute magnitudes is hard.  For many types of star, we don't really know their absolute magnitude and so we don't really know their distance.
For close-by stars we can get the distance by measuring the parallax (how far the star appears to move over a year due to the orbit of the Earth. Nearer stars appear to move more) From this we can work out absolute magnitude.
For other stars we can get their absolute magnitude in other ways. For example, a type of large bright star called a &quot;Cepheid variable&quot; will have a pulse rate P that is connected to it's absolute magnitude $M_\mathrm{v}$ by the following (empirically derived) formula:
$$M_\mathrm{v} = -2.43(\log_{10}P - 1) - 4.05$$
With this you can easily measure the period in days, and use that to find the absolute magnitude.  The apparent magnitude is easy to measure, it is how bright the star appears to be on Earth.
And with apparent and absolute magnitudes you can find the distance of the star.
Stars like Cepheid variables are called &quot;standard candles&quot;, since their brightness can be determined exactly