cancel
Showing results 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

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:

 Category Type Number Date Previous_REIS_number Next_REIS_number 12B RYT 45B 2023-05-09 07:11 65T 12B REIS 65T 2023-05-09 07:11 12B PAS 56T 2023-05-09 07:56 65T 78K 12B PAS 35G 2023-05-09 08:24 65T 78K 12B REIS 56C 2023-05-09 08:42 65T 78K 12B PAS 43V 2023-05-09 11:45 65T 78K 12B REIS 78K 2023-05-09 13:04 12B PAS 52B 2023-05-09 13:04 78K 23S 12B PAS 56H 2023-05-09 13:05 78K 23S 12B PAS 45P 2023-05-09 16:42 78K 23S 12B KUR 89L 2023-05-09 19:52 78K 23S 12B REIS 23S 2023-05-09 20:03 12F PAS 56H 2023-05-09 07:56 89L 12F PAS 45P 2023-05-09 08:24 89L 12F REIS 89L 2023-05-09 08:42 12F PAB 23S 2023-05-09 16:42 89L 65W 12F REIS 65W 2023-05-09 13:05 12F PAS 56H 2023-05-09 13:05 65W 12F PAS 45P 2023-05-09 16:42 65W 12F KUR 89L 2023-05-09 20:03 65W

2 REPLIES 2
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

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Helper I

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

Announcements

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 Monthly Update - June 2024

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

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
Top Kudoed Authors