Some bladder problems can cause similar behavior in fish suffering from food impaction. If you think food impaction might be the cause, a simple fix in many cases, probably by loosening food impaction, is to take a soft, cooked pea (either fresh, canned or frozen and then cooked), crush it and feed it to the fish. If this does not work, do not feed the fish for a few days, since fasting should also clear any food impaction.
As with any other disease or medical condition, it is important to always ensure the water quality in the tank is good. A partial change of water is a good idea, even after the pea trick works.