Where should I use median instead of average? Is there a general law, or rule of thumb, or rationale, when to use median and when average?
Although I know the difference and how they are computed, when I try to translate to simple English I would say in both cases that they both are a value that justly and fairly represents a big group of values of a certain category.
Examples:


*

*Grades across different subjects for a single student.

*Grades in one subject across students in one class.

*Time to close a ticket per worker of a support desk.

*Jail time given by a judge for a certain crime.

*Lap time in a 10 laps run for a certain runner.

*Monthly income per household in a given neighborhood.


So what should I use in each case above? And what is the general rule.
And as a side question, are there other types of aggregate functions other than median and average that relate to this?
 A: Although, there is no written rule about using mean and median, except the "outliers" advantage that median has, we will try to focus on the "absolute" and "relative" nature of the variable of interest. Additionally, we should also consider the "purpose" of that variable. Note that mean can still be used after removing the outliers in cases where calculating median makes little or no sense. Let's discuss the following examples:


*

*Grades across different subjects for a single student - See explanation for Q2. Then, the individual grade will in a way show the actual proficiency discounted/normalized by/for the level of difficulty of that exam. To arrive at the average overall proficiency, we will take the "mean" (since scores become comparable across subjects).

*Grades in one subject across students in one class - Assuming the level of difficulty of an exam affects every test-taker uniformly, it will be a better idea to consider the relative aspect, through measures like median, quartiles, etc to prepare the grades.

*Time to close a ticket per worker of a support desk - This information will probably be used as a report to customers as in how much time they can expect their query to be solved. Hence, mean, i.e. the expected value.

*Jail time given by a judge for a certain crime - "How much time should the next convict expect in jail?" Hence, mean.

*Lap time in a 10 laps run for a certain runner - In how much time can we expect the runner to finish the lap when he runs next time? Hence, mean.

*Monthly income per household in a given neighborhood - Most of the time, we will find such data with both upper and lower outliers. If we are going to present the average number as the economic situation, we tend to use the mean, generally after removing the outliers. If we are going to categorize people according to their income levels, like, say upper, medium, lower, we should use the median, or the quartiles.
Hope that makes sense.
A: It depends on the question you want to ask, more importantly from whose side you want to ask.
Lets take an example, what exactly do you want to know when you ask "what is the average salary of USA?", the underlying question that most likely you want to know is how likely I am to get this salary, in such case you are definitely asing the wrong question because only a few handful CEOs and top executives earning hundreds of million dollars in salary is pushing the national average high. Thats why median is a better metric for these. However if you were the government securities or treasuries wanting to know this, average wouldn’t be a bad metric for you.
Lets take another example, Now say you are launching a new product, you want to estimate the revenue each user brings in to your site . A common metric in such case used is “average revenue per user”, mainly because here the underlying question is how much more can my company earn, look now you stand on the other side and want to have an aggregated view.
To summarise the above two examples, if you yourself view it as a sample of the data your interests would be towards the median, whereas if you are a aggregator your interests would align toward the mean.
Now say if you are none, you are just a statistician want to portray both sides of pictures. Use median when you are not sure of the distribution of the data. 85% of natural data sets have been found to be skewed and more than 99% to have some sort of outliers. Median is robust to both skewness as well as outliers. Hence median has been by default the more popular choice to measure central tendency than mean.
However if you are very sure that your data is not skewed at all and has near perfect bell shaped distribution, you can use mean. But mind you median in this case too won't be too off from mean. So if you are new to statistics you can blindly go for median for just about everything.
As some answer already mentioned mean can be more useful in predictive problems and normalized sum problems but when it comes to a group representative selection use case nothing beats median which is what I tried to exemplify in the first couple of paragraphs of my answer.
A: I would agree with you in that both are significant when it comes to analyzing data. One thing you could keep in mind is that the mean of a data set can be easily affected by outliers. For example, if you have a skewed distribution, the mean of your data might not accurately represent the "center" of your data while a median will generally do better (in this case). 
