
2. Re: Reference line median does not match median aggregate calculation
brian howard Jul 18, 2016 10:40 AM (in response to Shinichiro Murakami)Here's a stripped down workbook demonstrating the problem.
The top part of the pane uses the Median() calculation, the bottom portion uses reference lines, and they show different values despite the same data source.

3. Re: Reference line median does not match median aggregate calculation
brian howard Jul 18, 2016 1:55 PM (in response to brian howard)After some more digging, I've found a few threads that shed some light on this.
First, Tableau uses different calculations for creating a median depending on whether it's an aggregate calculation or a reference line.
Second, this thread shows how to create reference lines from a calculated field that relies on the window_percentile function that works the same way as the median aggregation (e.g. "IF FIRST() == 0 THEN window_percentile(ATTR([Time to termination]),0.50) END").
But that was still giving me crazy answers until I found this question (more particularly the response by Jim Wahl) which suggests turning off aggregate measures (go to the Analysis menu and uncheck Aggregate Measures).
But more interestingly, turning off aggregate measures seems to solve the problem without the need for calculated fields. When I turn off aggregate measures, the default reference line's median calculation suddenly changes to match the Median() aggregate....
I'm glad I can now use the calculation I need, but why does turning off aggregate measures change how the median is calculated? What other effects might it have?

4. Re: Reference line median does not match median aggregate calculation
Shinichiro Murakami Jul 18, 2016 5:25 PM (in response to brian howard)I tried to understand why... in other word, tried to create number 501 and 676.
Then here is a calculation logic to generate both numbers.
Hope this can be some hints.
Using ID as unique line item.
Using "Time to Termination" as Dimension
Thanks,
Shin

5. Re: Reference line median does not match median aggregate calculation
Yuriy Fal Jul 19, 2016 3:09 PM (in response to Shinichiro Murakami)Hi all,
Shin is right with his investigation.
MEDIAN() aggregation is for the whole dataset
with the rowlevel granularity (defined by [id] in this case).
Median Ref Line is a Table Calculation
with the granularity defined by all Dimensions
on a view  [Time to termination] in this case.
If one put the [id] field to the Details shelf
of the [Time to termination] Green Pill (on Rows),
the view granularity for both Green Pills on Rows
would be the same, hence 501 on both.
Yours,
Yuri