Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Help getting value of a measure based on category index

I have three measures AveOnHand (beg inventory for batch), Needs (cumulative demand by date) and Balance ([AvgOnHand]-[Needs]).  I am working with dated batches of product. I need to add the final value of Balance from the oldest batch (index 4) to the beginning inventory of the next batch (index 5.)  In the following example, I need to add -750 to 1227. 


How might I accomplish this? I've spent lots of time searching around and trying various Dax solutions, but I can't get the desired result.

Thanks for any help!




Super User IV
Super User IV

Re: Help getting value of a measure based on category index

First, Please see this post regarding How to Get Your Question Answered Quickly:


Second, See my article on Mean Time Between Failure (MTBF) which uses EARLIER:


Third, it is probably something like:

Column =
  VAR __Batch = [Index]
  VAR __PreviousBatch = [Index] - 1
  VAR __OldestPreviousDate = MAXX(FILTER('Table',[Index] = __PreviousBatch),[FutureProdDate])
  VAR __PreviousBalance = MAXX(FILTER('Table',[Index] = __PreviousBatch && [FutureProdDate] = __OldestPreviousDate,[Balance])
  VAR __OldestCurrentDate = MAXX(FILTER('Table',[Index] = __Batch),[FutureProdDate])
  IF('Table'[FutureProdDate] = __OldestCurrentDate,[Balance] + __PreviousBalance,[Balance])



Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Helpful resources

Super Users of the Quarter - Q2 2020

Super Users of the Quarter - Q2 2020

Who are our Super User Superstars? Who made it to the top of the leaderboards? Get the answers!

June 2020 Community Highlights

June 2020 Community Highlights

Featured community members, changes to the Community, and more! Read up on recent Power BI community news.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors