Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

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.

Screenshot_39.png

 

 

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.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Take a look at my MTBF article, it has a similar kind of issue that it is trying to solve. You should be able to use it to create a column that flags a session as new based upon the duration from the previous row.

 

http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion

Take a look at my MTBF article, it has a similar kind of issue that it is trying to solve. You should be able to use it to create a column that flags a session as new based upon the duration from the previous row.

 

http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
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.

 

 

Screenshot_40.pngnew 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
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:

 

Screenshot_41.png

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.

If it works for you and gives you what you want, then it is correct! 🙂 

 

Glad my article could at least point you in the right direction!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Yeah it's working fine and I am getting correct results (as much I tested). thanks a lot for your help sir. Respect.

You need to "flip" your logic. So, instead of going "bottom up" you need to go "top down"

 

new duration in min = 
VAR next = MAXX(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(next;'Talend_GA sessions'[created_timestamp];MINUTE))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.