Retrieving last date with value

Hi,

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:

Equipment01/01-1902/01-1903/01-1904/01-1905/01-1906/01-1907/01-1908/01-1909/01-19
#1001111100
#2111100000

Module 2:

EquipmentIn service dateOut of service date
#103/01-1907/01-19
#201/01-1904/01-19

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

  • @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-23.png

     

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

     

    2019-10-15_17-58-35.png

     

    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

     

    2019-10-15_17-59-01.png

     

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

     

    2019-10-15_17-59-14.png

     

    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]

     

    2019-10-15_18-06-23.png

    For a result of:

    2019-10-15_18-06-49.png

     

    Hope this helps,

    Rob

     

     

     

     

Answers