In the first aliyah Pharaoh has a disturbing dream, where seven fat cows are eaten by seven skinny cows, and then a second dream where seven fat ears of grain are eaten by seven skinny ears. None of Pharaoh's wise men can interpret the dreams to Pharaoh's satisfaction. Pharaoh wasn't satisfied because he had dreamt the proper interpretation with each dream, but when he awoke he forgot the interpretation. Nevertheless he could tell if he was being told the correct interpretation.
In this situation Pharaoh's butler mentions that two years earlier Yosef did a perfect job of interpreting the butler's dream. So Pharaoh hastily gets Yosef out of prison to interpret Pharaoh's present dream.