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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
qwertzuiop
Advocate III
Advocate III

Date/Time Difference between first and last occurence ID

Dear Power BI Community

 

Hopefully with this visualisation I can better represent my desired output.

We are looking for the date/time difference of an ID from the first to the last Occurence

 

qwertzuiop_1-1686034333958.png

It is not necessarily important that the output is in the corresponding line. What is important is that somewhere there is information that, for example, ID MDY5MP takes approx. 3,999 days from first to lasttime (maybe best approach in a measure, no?)

 

Any ideas how to solve this problem?

Thank you very much for your contribution.

 

Cheers

qwertzuiop

1 ACCEPTED SOLUTION
Kishore_KVN
Super User
Super User

Hello @qwertzuiop , you have to group it by Member ID then you can do that. 

Use below measure to get the result as required. 

Duration = 
Var Start_Date = CALCULATE(MIN(Data[CS_Date]),ALLEXCEPT(Data,Data[CS_MessageID]))
Var Last_Date = CALCULATE(MAX(Data[CS_Date]),ALLEXCEPT(Data,Data[CS_MessageID]))
Var Result = DATEDIFF(Start_Date,Last_Date,DAY)
Return 
Result

Result will be in days.

 

If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!

View solution in original post

1 REPLY 1
Kishore_KVN
Super User
Super User

Hello @qwertzuiop , you have to group it by Member ID then you can do that. 

Use below measure to get the result as required. 

Duration = 
Var Start_Date = CALCULATE(MIN(Data[CS_Date]),ALLEXCEPT(Data,Data[CS_MessageID]))
Var Last_Date = CALCULATE(MAX(Data[CS_Date]),ALLEXCEPT(Data,Data[CS_MessageID]))
Var Result = DATEDIFF(Start_Date,Last_Date,DAY)
Return 
Result

Result will be in days.

 

If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.