It's structured on seven visions. First, three dreams/ visions are given to other people and the interpreted by Daniel, each vision being followed by a brief story. And, secondly, Daniel himself is given four visions.
I’ve glanced at several commentaries and none of them make this point. It seems a basic structural feature, and I think this confirms C S Lewis’ assessment that most modern scriptural commentators miss very obvious literary features (in his essay, “Fern Seeds and Elephants”).
The first three dreams/visions involve a progression. The first dream tells the Babylonian king, that his empire is splendid but will be followed by lesser empires at some unspecified time. The second dream is more threatening, telling the king that he will lose his sanity but will later be restored to his throne. And the third vision tells the king’s successor that he will lose his throne the same night as the vision appears.
Perhaps there's another progression involved, with each vision being less hidden than before. In the first, the king doesn't remember the dream, and Daniel has to reveal both the dream and its meaning. The king remembers the second dream, and Daniel again reveals the meaning. But the third vision is more public still – written on the walls of the king’s banquet hall.
Or at least, following my childhood picture Bible, I’ve always assumed that everyone saw the writing. Actually, we’re told that the king saw it (Dan 5:5) and that the wise men “could not read the writing or tell the king what it meant” (Dan 5:8). I think the wise men could see the letters but could not decipher them, let alone provide an interpretation. But I’ll accept that it’s an open question and perhaps the writing was seen only by the king (and by Daniel).
It could perhaps be like the situation where Daniel later sees the angel at the Tigris River. His companions cannot see the angel, although they sense there is something there and flee in terror (Dan 10:4, 7).