Try this before you do anything else - cut away the plug and a few inches of cable - and fit a new plug.
A very common problem with vacuums is a broken wire inside the cable near the plug - from tugging. Are you a tugger?
The wires slowly stretch and eventually come apart - sometimes making contact sometimes not.
When repairing cleaners I have found this to be the most common fault.