Making the assumption that it is newish, sounds like you need to return/exchange it or send it to DJI for repair. I don't think you are going to find any advice that will help you fix a bad or possibly disconnect compass.
Keep us updated on your progress.
Cheers