Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Create sessions based on timestamp

Hi All,

 

I have some data from GA in which I have session Id and DateTime field. My requirement is to look at the session Id and if the created_timestamp has a time difference of more than 30 mins it started counting it as a seperate session.

 

 

For Eg. in the image: For session Id 264611 I have many created_timestamps but the two marked with reds have a time difference of more than 30 mins. So my requirement is if I count all the sessions for the that particular session_id in a day.

6 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Greg_Deckler,

       

      I tried something like this with the help of your article: 

      and it retured me the below output. My question now is: How could I distinguish between 16th and 15th. Because for me there is a new session on 16th, if I calculate based on my >30 mins duration there is no session on 16th in that case.

       

       

      new duration in min = 
      VAR next = MINX(FILTER ('Talend_GA sessions';
                      'Talend_GA sessions'[session_id] = EARLIER('Talend_GA sessions'[session_id]) &&
                      'Talend_GA sessions'[created_timestamp] > EARLIER('Talend_GA sessions'[created_timestamp])
                      );'Talend_GA sessions'[created_timestamp])
                  RETURN (DATEDIFF('Talend_GA sessions'[created_timestamp];next;MINUTE))
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Greg_Deckler,

         

        The first solution works for me with some extra mesures.

         

        After this step I defined a mesaure to count sessions:

         

        count_sessions = CALCULATE( COUNT('Talend_GA sessions'[new duration in min]);FILTER('Talend_GA sessions';'Talend_GA sessions'[new duration in min]>30))

         That gave me a result like this:

         

        After that I defined another measure to add up the lost session count as you can see in the image above, there are three sessions as per the definition but it counts only two.

         

        count_sessions_final = [count_sessions] + [Total sessions]

        Here Total sessions is a mesure which counts the distinct session_ids.

         

        Please do let me know what I did is correct or not.