When I fly 12000ft, how can I know a distance from DME station? Is there any formula to know or measure distance from DEM?
Just to be clear, when you are asked for your DME from a station or using a DME fix, what is being expected is that you use what you see as the distance in nautical miles on the DME readout of your instrumentation. You're not expected to use your altitude to come up with the distance along the ground using trigonometry.
It's the slant distance they're expecting you to report and use regardless of your altitude and the actual distance over the ground.
I lifted the image off a Google search for "images of dme instrumentation", and they got it from https://www.cfinotebook.net/graphics/avionics-and-instruments/distance-measuring-equipment/DME-Slant-Range-Distance.jpg
DME is a slant distance. If you are asking for a lateral distance, that could be done using simple trigonometry taking the slant distance and field elevation of the DME station, and aircraft altitude to compute an azimuth from the station, thence a lateral offset can be computed.