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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
konradjonsson
Helper II
Helper II

how to identify previous value?

I have a table that include the following columns (except the 'Days between failure', which is part of the question).

 

TypeSerial numberSold_DateService_DateFailure time (days)Days between failureProduct
Sales10012010-02-17 00:00   X
Sales10022010-05-28 00:00   X
Service10022010-05-28 00:002013-08-12 00:001172735X
Service10022010-05-28 00:002011-01-19 00:00236236X
Service10022010-05-28 00:002011-05-02 00:00339103X
Service10022010-05-28 00:002011-08-08 00:0043798X
Sales10032010-01-26 00:00   X
Service10032010-01-26 00:002010-07-08 00:00163163X
Service10032010-01-26 00:002012-09-06 00:00954791X
       
   MTTF199,5  
   MTBF 354,3 

 

In order to calculate MTBF, I need to calculate the difference (in days) between each service occasion. In other words, for each row, I need to know what the previous value was.

In the example above, the Days between failure for row three is 735 (1172 - 437).

In the example above, the MTBF is 354.3 (=average(735;236;103;98;163;791))

My question is - for each row, how to identify the previous value, for the unique serial number? (if it is the first occasion, then the previous value should be zero).

(I do not see the need to create a separate table for this purpose)

 

Regards.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=if(ISBLANK(LOOKUPVALUE([Failure time (days)],Data[Service_Date],CALCULATE(MAX(Data[Service_Date]),FILTER(Data,Data[Serial number]=EARLIER(Data[Serial number])&&Data[Service_Date]<EARLIER(Data[Service_Date])&&Data[Type]="Service")),Data[Serial number],Data[Serial number])),Data[Failure time (days)],Data[Failure time (days)]-LOOKUPVALUE([Failure time (days)],Data[Service_Date],CALCULATE(MAX(Data[Service_Date]),FILTER(Data,Data[Serial number]=EARLIER(Data[Serial number])&&Data[Service_Date]<EARLIER(Data[Service_Date])&&Data[Type]="Service")),Data[Serial number],Data[Serial number]))

Hope this helps.

Untitled.png


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

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=if(ISBLANK(LOOKUPVALUE([Failure time (days)],Data[Service_Date],CALCULATE(MAX(Data[Service_Date]),FILTER(Data,Data[Serial number]=EARLIER(Data[Serial number])&&Data[Service_Date]<EARLIER(Data[Service_Date])&&Data[Type]="Service")),Data[Serial number],Data[Serial number])),Data[Failure time (days)],Data[Failure time (days)]-LOOKUPVALUE([Failure time (days)],Data[Service_Date],CALCULATE(MAX(Data[Service_Date]),FILTER(Data,Data[Serial number]=EARLIER(Data[Serial number])&&Data[Service_Date]<EARLIER(Data[Service_Date])&&Data[Type]="Service")),Data[Serial number],Data[Serial number]))

Hope this helps.

Untitled.png


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

amitchandak
Super User
Super User

Check this one

https://community.powerbi.com/t5/Desktop/Diff-with-previous-date/m-p/165650#M72317

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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