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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
amuola
Helper II
Helper II

How to find the last timestamp in a column for a certain activity

Hi

I would like to count the number of days between start and finish of a certain process as illustrated in the table below: “Log on” 8.11.18 and “Completed” 8.15.18 = 4 days. The problem is that the activity “Completed” appears in two different rows (the activity is for some reason done twice) and I will make sure that the formula counts the last one of the two “Completed rows”.

 

ActivityTimestamp

Log on8.11.18 0:00
Activity 18.12.18 0:00
Activity 28.13.18 0:00
Completed8.14.18 11:08
Completed8.15.18 11:32

 

 

Any idea?

 

Regards Amund

1 ACCEPTED SOLUTION

You should be able to focus in on the final datetime using LASTDATE.

 

The measure would be something like this:

Measure =
VAR MinDate = CALCULATE(FIRSTDATE('Table'[ActivityTimestamp]),'Table'[Activity]="Log on")
VAR MaxDate = CALCULATE(LASTDATE('Table'[ActivityTimestamp]),'Table'[Activity]="Completed")
RETURN DATEDIFF(MinDate,MaxDate,DAY)

View solution in original post

2 REPLIES 2

You should be able to focus in on the final datetime using LASTDATE.

 

The measure would be something like this:

Measure =
VAR MinDate = CALCULATE(FIRSTDATE('Table'[ActivityTimestamp]),'Table'[Activity]="Log on")
VAR MaxDate = CALCULATE(LASTDATE('Table'[ActivityTimestamp]),'Table'[Activity]="Completed")
RETURN DATEDIFF(MinDate,MaxDate,DAY)

Hi

 

Thank you so much, this works!

 

However, I have another column in the original table which is booking number – assuming this is a repetitive process for each booking number (adding one more column = Booking number), hence I would like to get the days for each distinct bookingnumber. Do you have any suggestions how to modify the measure in order to take this element into account?

 

Regards Amund

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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