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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
KristinaSp
Helper I
Helper I

Previous and next value by type and category

Hello,

 

I need to calculate previous and next value (type REIS) by category and type. Please, could you help with this issue

Example:

KristinaSp_0-1684432605203.png

CategoryTypeNumberDatePrevious_REIS_numberNext_REIS_number
12BRYT45B2023-05-09 07:11 65T
12BREIS65T2023-05-09 07:11  
12BPAS56T2023-05-09 07:5665T78K
12BPAS35G2023-05-09 08:2465T78K
12BREIS56C2023-05-09 08:4265T78K
12BPAS43V2023-05-09 11:4565T78K
12BREIS78K2023-05-09 13:04  
12BPAS52B2023-05-09 13:0478K23S
12BPAS56H2023-05-09 13:0578K23S
12BPAS45P2023-05-09 16:4278K23S
12BKUR89L2023-05-09 19:5278K23S
12BREIS23S2023-05-09 20:03  
12FPAS56H2023-05-09 07:56 89L
12FPAS45P2023-05-09 08:24 89L
12FREIS89L2023-05-09 08:42  
12FPAB23S2023-05-09 16:4289L65W
12FREIS65W2023-05-09 13:05  
12FPAS56H2023-05-09 13:0565W 
12FPAS45P2023-05-09 16:4265W 
12FKUR89L2023-05-09 20:0365W 

 

2 REPLIES 2
Greg_Deckler
Super User
Super User

@KristinaSp See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I saw that your article, this formulas does not work for my case. It does not consider category and type

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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