aggregategoogle-analytics-apitableau-apipageviewslevel-of-detail

Double aggregation in Tableau using LOD expressions


I am using Tableau to create a custom google analytics dashboard. I have a custom dimension named author in my google analytics view and I would like to group the date of the first page/view by author and by month having a counter. I successfully get the date of first page/view using MIN([Date]), but I don't figure out how to use LOD expressions to double aggregate a calculation. I tried the following expression, but tableau shows an error saying that the argument I'm trying to count is already an aggregation and can no longer be aggregated.

{INCLUDE [Author] : COUNT(MIN([Date]))}

What did I miss ?


Solution

  • If your are trying to find the minimum of your [Date] field by your [Author] field, you might want to construct a LOD calculation to find first date, by author like so:

    //Creates calculated field for [First Date by author]    
    {FIXED [Author] : MIN([Date])}
    

    You also have asked about 'double aggregating'. Let's say for example that you wanted find the minimum date, by author, but also by a [Topic]. In this case, you could write:

    //Creates calculated field for [First Date by author, by Topic]      
    {FIXED [Author],[PostTopic] : MIN([Date])} 
    

    It is also possible to nest FIXED statements within one another. Let's say for example that you wanted to show maximum [PageViews] for a single month by [Author] and also wanted to limit the time span under consideration to to the first 3 months that an author was publishing. In this case, you could write:

    //Creates calculated field for [Most page views in a single month within first 3 months, by Author]
    //Example assumes [Date] is a monthly (not daily) data
    { FIXED [Author], [Date] <= DATEADD('month', 3, [First Date by author] ) : MAX({FIXED [Author],[Date]:SUM([PageViews])})}