Scott Adams is the writer and creator of Dilbert. He has a formula for humor, which he calls the Six Dimensions of Humor. The concept here is that everybody has a different type of humor. Not everybody finds the same things funny. By combining different types of humor, it is more likely that more people can relate. The six dimensions of humor are naughty, clever, cute, bizarre, mean, and recognizable. The general rule is that for something to be funny, it needs at least two of the six dimensions of humor. More is better, but two is the minimum.
Fun fact: Dogbert's original name with Dildog.