Dishwasher does not always fill

Our dishwasher is very temperamental. When we start a cycle, it will not always fill with water. We hang around for a few minutes waiting for it. If it doesn’t start to fill, we spin the dial all the way around and try again. Eventually, it does fill, but it usually takes several attempts. Occasionally, it does start filling, but stops prematurely. When that happens, we again spin the dial and start over and it always fills for the appropriate time on the second attempt.