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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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!:
The Definitive Guide to Power Query (M)

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors