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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

latest date before the date of each row

I have a table for a production line, where each row is an individual product. One column contains the date and time where production started.

I want to calculate the time elapsed between this date, and the start of production of the last product made before (cycle time).

 

In other words, in a list of dates I want to identify the latest date before the date of each row. 

In Access I can do that by duplicating the table_1 to table_2, and looking for the maximum date in table_2 which is smaller than the current date in table_1.

In Power BI query I cannot figure out how to make this simple operation.

 

Any help will be greatly appreciated !

Regards

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column

 

=CALCULATE(MAX(Data[Date_Time]),FILTER(Data,Data[Date_Time]<EARLIER(Data[Date_Time])))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Hi,

 

My formula has to be written as a calculated column - not as a measure.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column

 

=CALCULATE(MAX(Data[Date_Time]),FILTER(Data,Data[Date_Time]<EARLIER(Data[Date_Time])))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

I've tried this solution but there goes an error (circular reference)

 

Could you please help?

Hi,

 

My formula has to be written as a calculated column - not as a measure.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

yes, in this way I tried back in March, and it worked !

thank you again

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi, I tried this solution and but it's not working ( a circular reference)

 

Could you help please?

Anonymous
Not applicable

Seems good at 1st test. Thanks !

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.