The symptom you describe exactly matches my wife's car. If you get cabin heat only when moving the problem is your aux coolant pump.
The pump is a brushless DC motor and internal failure of electronic parts make it stop running.
The pump is right below the MAF.
You can likely kick start the pump with a mechanical tap; ideally in such a way that twists the motor a bit.

Healthy motor winding signal east-west.
Unhealthy signal north-south.
I took these readings off a failed aux pump. I didn't have enough time to determine which part had failed. The faulty signal interfered with the starting torque. I was able to make the mirror spin every time if I gave it a starting twist
I noticed that my X5 has good cabin heat when stopped also warms faster. I noticed some strange noise under wife's hood tracked to the aux pump that works only sometimes and vibrates bad when it does work.