Retrieving last date with value



I have a module where I have time as dimension, as well as a list of equipment. The module is on daily level and has a value of either 1 or 0 depending on if the equipment is in service or not. These values are imported from another Anaplan model.

I then have a second module, where I have the same list of equipment as dimension. In this module I have 2 line items - "In Service Date" and "Out of service date".  What I am trying to do, and cannot figure out how to solve, is for the "In service date" show the first date with a 1 in it, indicating availability, and for the "out of service date", show the last date with availability.

Module 1:


Module 2:

EquipmentIn service dateOut of service date

Does anyone know what this formula would look like? Note that it is not possible for an equipment to be in service, then out of service, and then in service again - once it is out of service, it is out of service for good.

Any help is highly appreciated!

Best Answer

  • rob_marshall

    @fredrickstraube ,


    I have a couple of solutions for you.  First, create a SYS Global module where you can put in get the current period which is set in Time or it can be a manual update by the admin.  I have it as a formula:



    2019-10-15_17-56-13.pngI have my "transactional" module setup like you, just a few more inputs:




    I have added two line items with the following formulas:

    First In Service: IF Data > 0 THEN START() ELSE BLANK

    Out of Service: IF Data > 0 THEN START() ELSE BLANK




    The key difference is the summaries where I set them to First non-blank and Last non-blank.




    In the results module, I have the following formulas in case you wanted the Start and Stop over other periods (All Time, Current FY Year, and Current Month):

    In Service Date All Time: Equipment.First In Service[SELECT: TIME.All Periods]

    Out of Service Date All Time: Equipment.Out of Service[SELECT: TIME.All Periods]

    In Service Current Year: Equipment.First In Service[LOOKUP: SYS Global.Current Year]

    Out of Service Current Year: Equipment.Out of Service[LOOKUP: SYS Global.Current Year]

    In Service Month: Equipment.First In Service[LOOKUP: SYS Global.Current Month]

    Out of Service Month: Equipment.Out of Service[LOOKUP: SYS Global.Current Month]



    For a result of:



    Hope this helps,