1 Reply Latest reply on Sep 10, 2014 8:47 AM by Michel Caissie

    DATEDIFF aggregation problem

    Tomasz Szajniuk



      I am trying to do a cohort analysis following this document: http://kb.tableausoftware.com/articles/knowledgebase/cohort-analysis-tips


      However when I am trying to calculate months between first and subsequent purchases by using calculation DATEDIFF('month',[DateFirstPurchase],[DateKey]) there is an error that "Cannot mix aggregate and non-aggreate arguments with this function. Both [DateFirstPurchase] and [DateKey] are expressed as a date, where [DateFirstPurchase] formula is MIN([Datum]).

      Any ideas?


        • 1. Re: DATEDIFF aggregation problem
          Michel Caissie



          I guess that [DateFirstPurchase] is the result of a window calculation, so it`s the aggregation of multiple rows.

          This means that you need to aggregate DateKey with the function  ATTR(DateKey).


          Be aware that if you want to view the data at the day granularity  and  if DateKey is a DateTime with different time values, you would need to extract the day first. So you would have something like