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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Difference in hours between duplicates

Hi everyone 🙂

 

I am having a problem, hope you can help.

I need to have the differente in hours between duplicates. Example:

 

Date Time                   SESSION_ID

24/01/2020 10:00       100

24/01/2020 11:00       100

14/03/2020 12:00       290

16/03/2020 13:00       254

 

In session_ID column, there are two duplicates, the sessio_id=100.

I need to know the difference in hours between those sessions, which would be 1 hour.

I already have a measure that count how many times the same session_id appears. But am strugling with the rest.

 

Does anyone has any type of clue on how this could be done in power bi?

 

Thank you so much for your help 🙂

 

Stay safe,

 

Alena

1 ACCEPTED SOLUTION

Please find the attached solution after signature

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

11 REPLIES 11
amitchandak
Super User
Super User

@Anonymous ,

Not sure I got it completely. But a new column will give you count in each row

countx(filter(Table,Table[SESSION_ID] = earlier(Table[SESSION_ID])),Table[Date Time ])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak 

 

Thank you for your reply.

 

What would be the output of that formula?

 

I tried using it, and somehow you wrote the "earlier" formula incorreclty. Also, this earlier formula won't let me input a date time.

 

Thank you,

 

Alena

@Anonymous let me rephrase my question, same session id can have more than one duplicate, if yes, let's say session id  111 has 10 rows then how your calculation would look like? I'm not going to blindly provide a solution when I didn't know the problem in-depth.  



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k sorry for not being explicit.

If an id has 10 duplicates, I need to have the time difference in hours between consecutive id's. An example:

 

Session_ID   Date Time                    The column I need

111               10/04/2020 10:00            NaN

111               10/04/2020 11:00            1

111               10/04/2020 12:00            1

111               10/04/2020 15:00            3

111               11/04/2020 01:00            10

112               11/04/2020 10:00            NaN

111               11/04/2020 11:00            10

Please find the attached solution after signature

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak thank you so much for your solution. Looks like exacly what I need.

For some reason, it is constantly giving me a memory error. Even with small amounts of data. 

 

@Anonymous , check the new two columns were I split the calculations

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak thank you very much for your help. 

I think this wont work in Import Mode since it is always giving me the memory error.

 

And it doesnt work in direct query, right?

@Anonymous , I created it as a measure. Check Measure and Measure 2. No need to create columns

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
parry2k
Super User
Super User

@Anonymous do you expect one duplicate record for each session_id or it can be more than one? The solution will depends on the answer.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hey @parry2k 

Thank you for the reply.

 

There can be several id's. 

Up to 30 duplicates.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors