Expand my Community achievements bar.

## Median Time on Page

Level 1

I am trying to create this calculated metric using the median function in conjunction with time spent per visit, but it is not working. I get the same value all the way down the column, regardless of what date range or dimension i break it down by. I also tried using it with"total seconds spent" but got the same result. Any ideas?

6 Replies

Hi Shawn, can you give us some info on how you had the workspace set up? If you're able to provide enough info to where I can start with a blank workspace and work up to where I can clearly see all median values being the same, that would be the most ideal.

Level 1

Hi there,

here is an image of how I set up the median time per visit metric. On the workspace, I tried this metric with multiple dimensions, such as last touch channel and referring domain. All of them have the same median time per visit going down the column.

Attached is

Level 4

Did you get an answer from Adobe on this?  I have same problem!

Level 4

OK - I figured out what is going on!  The way functions work is not how I expected (and others asking this and similar questions).

Aggregate / Statistical functions are applied to the breakdown rows of data in the freeform table - as opposed to the raw data.  Here is a simple example.  You can see that the mean pageviews per visit column has the same value for all rows:

Pageviews per visit is defined like this:

Mean pageviews per visit is defined like this (note it includes a function):

Why does the mean function return 6.66 and why does the summary in the "Pageviews per Visits" column return 6.71?

6.66 is the average of the values in the "Pageviews per Visits" column - the average of 7 values.  That is how the Adobe functions work in calculated metrics.  The overall value in the "Pageviews per Visits" column is the total number of pageviews over the 7 days divided by the total number of visits over the 7 days.  The math for these helps you see why they are not the same thing:

Level 6

Ok, but any idea on how to achieve original request?

Level 5

Basic functions within Adobe Analytics fall into the categories of 'Row' or 'Table', its imperative to be mindful of which type you are trying to employ.

## Table Functions versus Row FunctionsA table function is one where the output is the same for every row of the table. A row function is one where the output is different for every row of the table.

Median is a 'Table' function.

Couple of ideas to get you close:

1.) Use a cumulative custom metric to evaluate where historically the 50% of visit break point is - then create a calculated metric for % of visits that are that value or lower.  This will allow you to trend if there is a change.

2.) Use nested if formulas to achieve a bucketed version of the median metric.  Something like (if visits shorter than x divided by all visits is > .5 then x)  You will need a number of if statements and need to start with your lower bucket.

There are a couple of screenshots in this tweet that provide direction.