Lets start with a basic BMW power sunroof reset. This will help when the battery has been disconnected.
If you have changed your battery sometimes the sunroof will only let you use the tilt function. 1. Tilt your BMW sunroof up. 2. Hold the tilt button in for at least 10 seconds. This should reset your sunroof and give you full functions again.
Some BMW power sunroofs have a recovery and reset mode. PRESS IN and HOLD the sunroof closure rectangular slide button for as much as 3 minutes. During this time the roof will open, close, slide etc. to re-calibrate the positions.