Planning Analytics

Planning Analytics

Get AI-infused integrated business planning

 View Only
  • 1.  Adding Months to a Date in TM1 Rules

    Posted Fri January 05, 2024 01:27 PM

    Adding Months to a Date in TM1 Rules

    Hello TM1 Users,
     
    I'm sharing a practical solution for adding a variable number of months to a given start date within TM1 Rules.
    The aim is to handle month and year adjustments intelligently. Here's the rule we crafted:
    ['Expired_Date'] = N: DAYNO(DATES( YEAR(DATE(['Start_Date'] - 21916)) + INT((MONTH(DATE(['Start_Date'] - 21916)) + ['Periods'] - 1) / 12) , MOD(MONTH(DATE(['Start_Date'] - 21916)) + ['Periods'] - 1, 12) + 1 , 1 )) + 21916 - 1;

    This rule efficiently calculates a new date by adding the specified number of months to 'Start_Date', ensuring the month value is capped at 12, and adjusting the year accordingly. The resulting date is then converted to a numerical value using DAYNO, providing the last day of the previous month.
     
    Feel free to use and adapt this rule for specific scenarios or make suggestions for alternative approaches. 

    ---

    Suggestion for TM1 Rules Functions Enhancement:

    In the spirit of continually improving TM1 functionality, I'd like to propose some enhancements to the existing TM1 rules functions. These suggestions aim to streamline date-related calculations and improve the user experience:

    1. Introduction of a DATE Function without 21916 Subtraction:

      • It would be beneficial to have a DATE function that doesn't require the 21916 subtraction for TM1 date fields. Simplifying date manipulations would improve clarity and reduce the need for additional adjustments.
    2. Direct Support for Numerical Dates in Year, Month, and Day Functions:

      • The inclusion of Year, Month, and Day functions that can directly accept numerical dates from TM1 date fields would enhance the efficiency of date-related calculations. Eliminating the need for additional conversions would make rules more straightforward.
    3. Consistent Four-Digit Year Handling:

      • Ensuring that all year inputs and outputs within TM1 rules function consistently use four-digit years would contribute to a standardized approach. This consistency would enhance the reliability and readability of TM1 rules.

    These enhancements would simplify rule development, reduce potential sources of error, and improve overall usability. Your thoughts and feedback on these suggestions are highly valuable. Let's work towards making TM1 an even more powerful tool for our community.

    Best, Asgeir



    ------------------------------
    Asgeir Thorgeirsson
    ------------------------------


  • 2.  RE: Adding Months to a Date in TM1 Rules

    Posted Mon January 08, 2024 12:33 AM

    Hi Asgeir,

    Re "Introduction of a DATE Function without 21916 Subtraction:" 

    Try setting UseExcelSerialDate = T ? https://www.ibm.com/docs/ru/planning-analytics/2.0.0?topic=pitf-useexcelserialdate 

    Cheers,

    Y



    ------------------------------
    Cheers,
    Yuri
    ------------------------------



  • 3.  RE: Adding Months to a Date in TM1 Rules

    Posted Tue January 09, 2024 06:13 AM

    Thank you Yuri!

    If I set the UseExcelSerialDate = T, do  I then need to rewrite the affected code in all rules and processes?



    ------------------------------
    Asgeir Thorgeirsson
    ------------------------------



  • 4.  RE: Adding Months to a Date in TM1 Rules

    Posted Wed January 10, 2024 12:25 AM

    > If I set the UseExcelSerialDate = T, do  I then need to rewrite the affected code in all rules and processes?

    Yup, it's a global server setting that makes the current functions behave so that they don't need that 21916 offset.



    ------------------------------
    Cheers,
    Yuri
    ------------------------------