Product:
Cognos Analytics 11.0.12
Microsoft Windows 2016 server

Problem:
How limit the login to Cognos Connection to only to groups in the LDAP (active directory)?

Solution:
Use the LDAP connector in Cognos Configuration, and limit the users to be able to login only if they belong to two CN.
The “User Lookup” is used when you do not use SSO, and you let the BI (CA11) prompt the user for the user name and password. Change this to include the groups that the person must be part of to be able to login. Below a example how it can be;

(&(|(legacyuid=${userID})(uid=${userID}))(status=ACTIVE)(|(memberof=cn=Cognos_TM1_Contributor,cn=Cognos Groups,cn=UserGroups,ou=Global,o=CompanyA.com)(memberof=cn=Cognos_TM1_Modeler,cn=Cognos Groups,cn=UserGroups,ou=Global,o=CompanyA.com)))

“External identity mapping” is only used when you use SSO from IIS, to login to the BI server (CA11). You should change this to cover the same groups as the other one to make it act the same if it is using SSO or not.

(&(|(legacyuid=${replace(${environment(“REMOTE_USER”)},”CompanyA\\”, “”)})(uid=${replace(${environment(“REMOTE_USER”)},”CompanyA\\”, “”)}))(status=ACTIVE)(|((memberof=cn=Cognos_TM1_Contributor,cn=Cognos Groups,cn=UserGroups,ou=Global,o=CompanyA.com)(memberof=cn=Cognos_TM1_Modeler,cn=Cognos Groups,cn=UserGroups,ou=Global,o=CompanyA.com)))

In above lines, the user that is part of group Cognos_TM1_Contributor or Cognos_TM1_Modeler in LDAP, can login to Cognos. Good if you have a CA11 server setup, that only authenticate users that should use TM1(Planning Analytics 2.x).

(status=ACTIVE)
Check that the user is active in LDAP

legacyuid=${userID}
Compare the userid with the LDAP field Legacyuid

You have to change cn= and ou= values to match your LDAP setup.

Base Distinguished Name, should be the root of the LDAP directory.

How setup LDAP  (from the web)
In every location where you installed Content Manager, open IBM Cognos Configuration.
In the Explorer window, under Security, right-click Authentication, and then click New resource > Namespace.


In the Name box, type a name for your authentication namespace. LDAP
In the Type list, click the appropriate namespace and then click OK.

The new authentication provider resource appears in the Explorer window, under the Authentication component.
In the Properties window, for the Namespace ID property, specify a unique identifier for the namespace. Should be same as namespace name.
Specify the values for all other required properties to ensure that IBM Cognos components can locate and use your existing authentication provider.
If you want the LDAP authentication provider to bind to the directory server by using a specific Bind user DN and password when you perform searches, then specify these values.

If no values are specified, the LDAP authentication provider binds as anonymous.

If external identity mapping is enabled, Bind user DN and password are used for all LDAP access. If external identity mapping is not enabled, Bind user DN and password are used only when a search filter is specified for the User lookup property. In that case, when the user DN is established, subsequent requests to the LDAP server are run under the authentication context of the user.
If you do not use external identity mapping, use bind credentials for searching the LDAP directory server by doing the following step:
Ensure that Use external identity is set to False.
Set Use bind credentials for search to True.
Specify the user ID and password for Bind user DN and password.

If you do not specify a user ID and password, and anonymous access is enabled, the search is done by using anonymous.
Check the mapping settings for the required objects and attributes.

Depending on the LDAP configuration, you may have to change some default values to ensure successful communication between IBM Cognos components and the LDAP server.

LDAP attributes that are mapped to the Name property in Folder mappings, Group mappings, and Account mappings must be accessible to all authenticated users. In addition, the Name property must not be blank.
From the File menu, click Save.
Test the connection to a new namespace. In the Explorer window, under Authentication, right-click the new authentication resource and click Test.

You are prompted to enter credentials for a user in the namespace to complete the test.

Depending on how your namespace is configured, you can enter either a valid user ID and password for a user in the namespace or the bind user DN and password.

More information:
https://www.ibm.com/support/knowledgecenter/en/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.inst_cr_winux.doc/t_ldapauthentication_process-element.html

To bind a user to the LDAP server, the LDAP authentication provider must construct the distinguished name (DN). If the Use external identity property is set to True, it uses the External identity mapping property to try to resolve the user’s DN. If it cannot find the environment variable or the DN in the LDAP server, it attempts to use the User lookup property to construct the DN.

Product:
Planning Analytics Workspace 35
Linux Red Hat

Problem:
You have no access to the paw, and a restart of the docker containers with command  ./paw.sh stop  and  ./paw.sh  did not help.

If you click “validate” inside the Workspace administration page, you get Error getaddrinfo ENOTFOUND on all the server links.

Error Message:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET.
Reason: DNS lookup failure for: wa-proxy

Workaround:
Restart the linux box.
Login to the linux server with PUTTY.
Change to root user with command:
sudo su – root
Restart the linux server with command:
init 6

Try again after a few minutes.

Product:
Cognos Analytics 11.0.12
Microsoft Windows server 2016

Problem:
When user create a new report and want to add a picture, the default folder is the old /samples/images, but in CA11 the new folder is /webcontent/bi/images in most cases.

Suggested solution:
The default value of the Image picker tool in report studio of CA11, is stored in a JS file.
For version 11.0.12 that file is _WEK_async.js
Copy the file _WEK_async.js from the gateway server at c:\Program Files\ibm\cognos\analytics\webcontent\bi\pat\dialogs to your laptop.
Open the file _WEK_async.js in NOTEPAD++


Change the first occurrence of “../sample/images/” to “../images/” and save the file.
Rename the original _WEK_async.js to _WEK_async.js.org
Copy your new _WEK_async.js file to the folder on the gateway server c:\Program Files\ibm\cognos\analytics\webcontent\bi\pat\dialogs

Start a new browser session from you laptop.
Under internet options clear the cache and cookies, before you test again.

Surf to you https://cognosanalyticsserver/ibmcognos/bi/v1/disp
Start a new report
Choose the blank Layout template.
Expand to image tool on left side and double click it, to add it to the report.
Double click the icon and the default folder should be ../images.

If it does not work – try by restarting the Internet Information Server;
Go to the windows gateway server via RDP.
Start a DOS prompt as administrator
Enter IISRESET to restart the IIS services.

How find the json file
In future versions of CA11 this location of value is in a different file.
You have to start a IE browser, hit F12 and select NETWORK and start to capture. Surf to your CA11 website and create a new report.
Then when you open the image dialog, you will find in the first lines the file that it is using – in the list of files in the DEBUG IE Window.

More information:
https://www.ibm.com/mysupport/s/question/0D55000005IbHW0CAN/default-imgae-picker-url?language=en_US

Product:
Cognos Analytics 11.0.12
Microsoft Windows Server 2016

Issue:
When open up the administration tab from Cognos connection in CA11. You click on the system link on the left in IBM Cognos Administration. You see only the spinning wheel and the text “Working…” for a long time….

Error message:

badgateway

Suggested solution:
Stop the IBM Cognos services, and start them in correct order slowly.
To make sure that they come up correct.

 

More information:
http://www-01.ibm.com/support/docview.wss?uid=swg21496531

Order to Restart Cognos and TM1 Servers

Product:
Cognos Analytics 11.0.12
Microsoft Windows Server 2016

Problem:
After a reboot the Cognos BI Service does not start.

Error message in Cognos Configuration:
CFG-ERR-0103 Unable to start IBM Cognos service. Execution of the external process returns an error code value of ‘-1’.

Error message in Windows services when starting is that the password is wrong.

Possible solution:
A group policy have removed the service account for Cognos, from the local windows policy:
“Log on as a Service”. Add the Cognos windows service account back to the group.
Go to control panel – administration tools
Go to Local Security Policy
Expand Security settings – Local Policies – User Rights Assignment.
Click on Log on as a service.
Click Add user or group.
Add your user, and click OK all the way.

or you can enter the password again, then it will be automatically added to the group.

 

More Information:

https://www-01.ibm.com/support/docview.wss?uid=swg22002530

Product:
Cognos Analytics 11.0.12
Microsoft Windows Server 2016
Oracle 12 Database

Issue:
After changing the IBM Cognos service to use a windows service account instead of local system, the Cognos Analytics service does not start.

Error Message:
15:42:12, ‘LogService’, ‘StartService’, ‘FAILED’.
15:42:12, ‘LogService’, ‘StartService’, ‘Success’.
15:42:12, CAF-WRN-0010 CAF input validation enabled.
15:42:12, CAF-WRN-0021 CAF Third Party XSS checking disabled.
15:42:17, ‘ContentManager’, ‘getActiveContentManager’, ‘Failure’.
DPR-CMI-4006 Unable to determine the active Content Manager. Will retry periodically.
15:42:17, CM-CFG-5063 A Content Manager configuration error was detected while connecting to the content store. CM-CFG-5036 Content Manager failed to connect to the content store. The connection string is “jdbc:oracle:thin:@servername.domain.com:1521/instancename.domain.com”. The error encountered is: “ORA-00604: error occurred at recursive SQL level 1 ORA-12705: Cannot access NLS data files or invalid environment specified ” Cause: ORA-00604: error occurred at recursive SQL level 1 ORA-12705: Cannot access NLS data files or invalid environment specified Stack trace: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 ORA-12705: Cannot access NLS data files or invalid environment specified at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)

Solution:
Change the region settings on the server for the Service account to English (United States).

More Information:
The Oracle driver have a NLS setting in registry, the windows region setting need to match this value to make the Cognos service to start.

Start REGEDIT and go to [HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient12Home1] check there the value “NLS_LANG”=”AMERICAN_AMERICA.WE8MSWIN1252”.

http://www.dba-oracle.com/t_ora_12705_resolution.htm

Product:
Cognos Analytics 11.0.12
Microsoft Windows 2012 Server
TM1 10.2.2

Issue:
The IBM Cognos Windows service look like it is started in Windows, but when you try to login you get a message that the page can not be shown. When starting Cognos from Cognos configuration you get message CFG-ERR-0106 … did not receive response from the IBM Cognos service in the time allotted. You can not surf to http://servername:9300/p2pd/servlet
The firewall is not blocking the connection.

Possible solution:
A other software was installed on the Cognos BI server, that uses JAVA and have set JAVA_HOME, JDK_HOME and JRE_HOME as windows variables. You can see this by enter SET at a CMD prompt on the server. This have given that Cognos have used the wrong java version.

Adjust JAVA_HOME to point to the Cognos java folder.

More information:
https://www.ibm.com/support/knowledgecenter/en/SSEP7J_10.2.1/com.ibm.swg.ba.cognos.c8pp_inst.10.2.1.doc/c_reviewthedefaultsettings.html
https://www-01.ibm.com/support/docview.wss?uid=swg21342592

Product:
Planning Analytics 2.0.5
Microsoft Windows Server 2016

Recommend to have only the valid TM1S.CFG functions in the file, the default values change with each version of TM1. You need to check the values, and remove the unnecessary ones. https://www.ibm.com/support/knowledgecenter/en/SSD29G_2.0.0/com.ibm.swg.ba.cognos.tm1_inst.2.0.0.doc/c_parametersinthetm1s.cfgfile_n1503fe.html

(This is a copy of text on this site – they contain good information)
https://cubewise.com/blog/adjusting-server-configuration-planning-analytics/

Planning Analytics or TM1 server v11 comes with a host of new features. In order to get best performance and control behavior of the TM1 server if you are upgrading or considering upgrading to PAL then you should make sure that as a minimum you optimize your server configuration file (tm1s.cfg) to get the most out of the latest version. This article is part of our series on upgrading from TM1 to Planning Analytics. To get an overview of other areas to consider please refer to this topic.

Not all the parameters examined here are strictly brand new to v11 some have been around for a while or have changed default values or might now be redundant and therefore require a revisit.

One of the most significant changes to TM1 server behavior between versions 10.2.2 and 11.x is that almost all server configuration parameters are now dynamic. Even parameters concerning login and security are now dynamic. The parameters remaining static or immutable for the duration of the server session are now only a handful (where also it must be said that static makes sense) e.g. AdminHost, ServerName, DataDirectory, PortNumber. This is a huge change which should be acknowledged and hats off to IBM for achieving this.

tm1s.cfg parameters worth revisiting

  • HTTPPortNumber (static, default=5001) Determines the port number used by the Rest API. With the Rest API becoming the default API for the TM1 server it is important to set this parameter and not use the default value.
  • HTTPSessionTimeoutMinutes (dynamic, default=20) Determines the idle timeout for Rest sessions. We suggest matching the value of HTTPSessionTimeoutMinutes to IdleConnectionTimeoutSeconds.
  • UseSSL (static, default=T) Determines whether the server uses encrypted communication.
  • MaximumCubeLoadThreads (static, default=0) By default this parameter is disabled. In most situations Cubewise has recommended enabling. However, this recommendation changes with Planning Analytics as the new parameter MTCubeLoad should be used in its place. Having this parameter enabled can cause the server to crash during start-up in PA. MaximumCubeLoadThreads should now be set to 0 or removed from the tm1s.cfg file.
  • MTQ (dynamic, default=ALL) Multi-Threaded Query mode is now enabled by default to use all available cores (default value ALL or -1). Our recommendation however remains to set MTQ=-2 which will set MTQ to use all available cores less one which allows other operations on the server to be processed even under peak load from the TM1 server.
  • MTQQuery (dynamic, default=T) Determines whether TI processes utilize MTQ to materialize data source cube views.
  • PersistentFeeders (static, default=T) Persistent Feeders are now enabled by default allowing for faster server load times (at the cost of additional disk consumption for .feeders files and longer time to save all server data). The default value is recommended.
  • IntegratedSecurityMode (dynamic, default=1) This parameter is now dynamic, meaning for example that login method could be changed from CAM to TM1 security or vice versa while the server is in session. This has been discussed previously on our blog here.
  • UserDefinedCalculations (dynamic, default=T) We are including this parameter here because as of the latest 2.0.x PAL release user defined calculations are not supported in the new Rest based clients (Workspace, PAX) and it remains unclear whether or how UDCs will be supported in the future.

Brand new parameters

  • EnableNewHierarchyCreation (static, default=F) Alternate hierarchies are the banner new feature of Planning Analytics however are disabled by default. To enable hierarchies this parameter must be set to T. If you plan on implementing hierarchies make sure you also read our blog posts on the changes you need to consider to rules and TI processes as this can have far reaching impacts on your model.
  • MTCubeLoad (dynamic, default=F) This parameter replaces MaximumCubeLoadThreads. With MTCubeLoad cubes are still loaded in serial but multiple threads are used to load each cube. We recommend enabling this feature as this dramatically decreases server load times. The feature is disabled if MTQ=0 or MTQ=1.
  • IndexStoreDirectory (dynamic, default=DataDirectory) When MTCubeLoad is enabled this parameter defines the directory where index and bookmarks are stored to further optimize the server load phase. We recommend setting a directory other than the data directory.
  • MTFeeders (dynamic, default=F) Enables multi-threaded feeder evaluation during saving of rules or running the CubeProcessFeeders function. Enabling this function is recommended as this can significantly speed up saving of rules.
  • MTFeeders.AtStartup (dynamic default=F) Enables multi-threaded feeder evaluation during the server load phase. Combined with MTCubeLoad this can lead to dramatic reduction of startup times to a level comparable to the load time achieved with Persistent Feeders. We recommend enabling this feature.
  • PreallocatedMemory.Size, PreallocatedMemory.BeforeLoad (dynamic, default=F) These parameters can be used to fine-tune the behaviour of MTCubeLoad.
  • CreateNewCAMClients (dynamic, default=T) This parameter was introduced in 10.2.2 FP5 so is not strictly new with PA but due to the recent introduction is probably still unknown to most administrators. Setting this parameter to F disables the creation of new clients in a server using CAM authentication. This can reduce locking contention experienced when new clients attempt to log in.
  • EnableSandboxDimension (dynamic, default=F) Enabling this parameter allows sandboxes to be used as a virtual dimension when querying cubes. This is a fantastic feature however should be used with caution as once enabled all Rest and MDX queries will expect sandbox to be addressed as the 1st dimension in all cube queries.
  • EnableTIDebugging (dynamic, default=F) Debug mode for TurboIntegrator is another valuable new feature which is disabled by default. We recommend enabling this parameter on all non-production servers. The default value can be left for production environments where step-through debugging is not required. However, as the parameter is dynamic it can be enabled if needed.

In summary

Planning Analytics has several new features which require administrators to change default server configurations to access the new features. Even if you don’t plan on implementing alternate hierarchies we recommend using all of the new parameters listed above. When launching new features IBM has a history of first disabling new features by default and in later releases changing the default behaviour. Examples of this can be seen with ParallelInteraction, PersistentFeeders and MTQ which were all initially disabled by default but are now enabled by default. We would expect the default values for EnableNewHierarchyCreation, MTCubeLoad & MTFeeders to all switch to being True within the next few releases.

Should you want to delve even deeper into optimizing tm1s.cfg parameters the Cubewise Code blog has a good article on this topic.

Product:
Planning Analytics 2.0.5
Microsoft Windows Server 2016

(this is a copy of text from IBM site)
https://www-01.ibm.com/support/docview.wss?uid=ibm10737313&myns=swgimgmt&mynp=OCSSD29G&mync=F&cm_sp=swgimgmt-_-OCSSD29G-_-F

Summary

The purpose of this document is to help with understanding and managing the memory utilization of the TM1 Application Server.

Understanding of Usage

Your TM1 Application Server (JAVA) memory is impacted by the following applications:

  • TM1Web (viewing/exporting data)
  • PMPSVC (viewing/exporting data)
  • Planning Analytics for Excel (PA for Excel, which uses the PMHub service on the TM1 Application Server)
  • Planning Analytics Workspace (if used to display PA for Excel/Perspectives reports)
  • Operations Console (obtaining server status/logging data)

As much as one would like to know what the best settings are or how much memory is required to host the TM1 Application Server, the answer does not come easy.  The following questions must be taken in to account and even with answers to the following questions, only load/stress testing can provide an accurate estimate to the resources required for your specific load:

  • How many concurrent users are expected?
  • What application(s) are users expected to use?
  • Are users doing reporting only or is data entry included?
  • How much data is to be consumed by a user?  (how many rows/columns/cells)
  • How much data is expected to be exported?
  • Do web/excel books contain more than one tab?  (is it really 1 report, or 20 reports under 1?)

Applications Settings / Governors

To get a better handle on your TM1 Application Server memory management, the below safeguards/settings should be introduced.  It is recommended to implement more restrictive safeguards, raising the restrictions as required and where it makes sense to do so.

TM1Web (via /tm1_64/webapps/tm1web/web-inf/configuration/tm1web_config.xml):

<!– If specified, sets a limit for the maximum number of cells in the workbook file. It will not be possible to open workbooks with a number of cells that exceeds this limit. Leaving this blank will allow all workbooks to be opened. –>
<add key=”WorkbookMaxCellCount” value=”500000” />

<!– If specified, sets a threshold for limiting of exports using the number of cells. If the set threshold is exceeded when performing an export (looped exports will reach this multiplicatively), then the export will not be allowed for that user. Is applied for all users, and for  Websheets and CubeViewer. Leaving this blank will allow for classic-style exporting with no cell count limitations. –>
<add key=”ExportCellsThreshold” value=”200000” />

<!– MaximumSheetsForExport: Maximum number of sheets allowed to Export –>
<add key=”MaximumSheetsForExport” value=”50” />

<!– Determines the maximum number of exports that can occur concurrently. If less than or equal to zero, will allow virtually unlimited concurrent exports (2147483647 max). The default value is 5. –>
<add key=”MaximumConcurrentExports” value=”2” />

<!– CubeViewerRowPageSize: Number of rows to fetch in a page of cubeviewer –>
<add key=”CubeViewerRowPageSize” value=”100” />

<!– CubeViewerColumnPageSize: Number of columns to fetch in a page of cubeviewer –>
<add key=”CubeViewerColumnPageSize” value=”20” />
Planning Analytics for Excel (via Options Menu):

  • Application Settings:
    • Auto spread consolidated input, recommended value: disabled
      •   If not required, disable this setting to prevent users from accidentally spreading
      •   If spreading is allowed, ensure users are educated so that a spread is not attempted on an intersection that spans too many cells
  • Exploration or list settings:
    •  Data display row limit, recommended value: 5000
      •   Reduce the number of rows displayed to ensure a larger than necessary query is no executed
    •  Expand member limit, recommended value: 2000
      •   Reduce the number of rows displayed to ensure a larger than necessary query is no executed
  • Planning Analytics for Excel Design Recommendations:
    • Ensure that Zero Suppression is enabled where possible, to prevent larger than necessary queries
    • Do not include too many sheets/tabs in a single book, create multiple reports where possible
    • Ensure the Excel Sheet does not contains many unnecessary blank/empty columns/rows

 

Tuning the JAVA Process

The TM1 Application Server sits on a Websphere Liberty Application Server, which utilizes the JAvA platform.  The details in this section can assist you with further tuning of the JAVA Process for the TM1 Application Server, however as mentioned earlier in this document – only a proper test/load plan can ensure a successful deployment.

To fine tune the TM1 Application Server’s JAVA Process, edit the jvm.options file (found in \tm1_64\wlp\usr\servers\tm1).  Consider adding the following entries, below the existing jvm.options settings (or updating any settings that may already exist).  Values should be adjusted accordingly to available resources, for example – don’t allocate an Xmx of 24576m if you have less than 32GB of RAM on the server.

  • -Xmx12288m
    • Xmx specifies the maximum memory allocation pool (heap) for a Java Virtual Machine (JVM)
      • Xmx is more commonly set using Cognos Configuration.  Changes to Xmx in the jvm.options file will take precedence.
      • Xmx should NOT exceed 24576m, as additional performance problems may be encountered.
  • -Xms12288m
    • Xms specifies the initial memory allocation pool on process startup.
    • Xms should reflect the same value specified by the Xmx parameter.
  • -Xmn6144m
    • Xmn sets the size of the new (nursery) heap.
    • Xmn should be set to half of the value specified by the Xmx parameter.
  • -Xgcpolicy:balanced
    • A garbage collection policy of balanced is recommended when the Xmx exceeds 8192m
    • Depending on application usage, a different garbage collection policy may prove beneficial to performance
      • If using TM1Web, a policy of balanced is recommended
      • If Planning Analytics for Excel is the only application using the TM1 Application Server, a policy of gencon may be better suited
        • Usage of the application, size of reports, number of users all come in to effect.  Both policies should be tested accordingly.
  • -Xverbosegclog:${bin_path}/verbosegc_%Y%m%d.%H%M%S.%pid.log,1,20000
    • Enabling Verbose Garbage Collection logging is recommended
    • The performance impact of having the logging enabled is negligible
    • Should any problems arise with the JAVA process, the output of the Verbose GC logs may prove beneficial to understanding root cause

Using the settings above, the entries in the jvm.options file will look like:
-Xmx12288m
-Xms12288m
-Xmn6144m
-Xgcpolicy:balanced
-Xverbosegclog:${bin_path}/logs/verbosegc_%Y%m%d.%H%M%S.%pid.log,1,20000

 

 

Additional Information

The following documents may prove useful in troubleshooting issues related to the TM1 Application Server

How to Troubleshoot a TM1 Application Server Hang
https://www-01.ibm.com/support/docview.wss?uid=swg22002262

How to Troubleshoot a TM1 Application Server Crash
http://www-01.ibm.com/support/docview.wss?uid=swg22002285

Product:
Planning Analytics 2.0.5 workspace
Microsoft Server 2016

Problem:
You get value in to the TM1 application, from a yearly cost of company car, and you want to know what the monthly cost is. Where you have the values for start date, and the accumulated sum for the month.

Starting solution:
This show part of the solution, to get you to understand the ParseDate function.
You must expand this solution to get a fully working TI process.

You can a find better solutions here:
http://www.tm1forum.com/viewtopic.php?t=9736

 

Login to PAW (Plannig Analytics Workspace) and your application.
ti1
Click on the pencil to make it blue so you are in edit mode.
ti2
Right click on dimensions to create a new dimension
ti3
Enter the name of the dimension and click create
ti4
Click OK and click on enter new members
ti5
ti6
Enter StartDate and click on commit
ti7
click on plus sign and select after selection to add a new member of the dimension.
ti8
Enter this values – this will be part of our cube to show the result.
ti9
Select the Breakdate and right click to set format to Date, repeat for StartDate.
ti10
Click on the show members attributes to see the format.
Create a new dimension named Result.Log with only one member.
ti11
ti12
Right click on cubes to create a new cube of above dimensions.
ti13
Mark Result.Event and Result.log and click arrow to move them over.
Enter Result Cube as name of the cube, and click on Create.
ti14
Click on the plus sign to add a new sheet. Select a boxed template.
ti15
Select the cube and right click and select Add new view
ti16
Click on the box and on the icon to change row and columns value. So you get this;
ti17
ti18
Right click on process to create a new process. Name the process AmountCalculated.
ti19
Expand the code window so you see most of it below the cube view.
ti20
Click on parameters tab, and click on plus sign to add input parameters. Here we will enter the values to test the process. In your solution you may get this values from a file instead.
ti21
Enter above names and start values. (p is to show it is a parameter variable)
ti22
Enter script tab, to enter your code.
Enter below code under Prolog End: Generated Statements

# define the cube and dimensions to work with
sDimName = ‘Result.Log’;
sCubename = ‘Result Cube’;

nBreakDateA = ParseDate( pBreakDateA, ‘yyyyMMdd’,0 );
nStartDateA = ParseDate( pStartDateA, ‘yyyyMMdd’,0 );

# write variables values to txt file in servers log folder for debug
asciioutput (‘../logfiles/debuglog1.txt’, str(nBreakDateA,8,2),str(nStartDateA,8,2) , numbertostring(pTotalAmountA));

# check if it is before break date then divide with 12
if (nStartDateA < nBreakDateA);
nMonthAmountA = pTotalAmountA / 12;
else;

# check if the distance is not in the same year
nStartYear = stringtonumber( subst (pStartDateA, 1,4));
nEndYear = stringtonumber( subst (pTotalDateA, 1,4));

# write variables values to txt file in servers log folder for debug
asciioutput (‘../logfiles/debuglog3.txt’, numbertostring(nStartYear),numbertostring(nEndYear) , pStartDateA, pTotalDateA );

if (nStartYear <>  nEndYear);
nTotalDateA = ParseDate( pTotalDateA, ‘yyyyMMdd’,0 );
nResult=  ((YEAR(DATE( nTotalDateA  )) – YEAR(DATE( ( nStartDateA ))) )*12)+ (MONTH(DATE( nTotalDateA )) – MONTH(DATE( ( nStartDateA ))) ) ;

# write variables values to txt file in servers log folder for debug
asciioutput (‘../logfiles/debuglog4.txt’, numbertostring(nStartYear), numbertostring(nEndYear) , numbertostring(nResult)  );

# if total is far from start date to today – you use the same formula  but nResult is total number of months
nMonthAmountA = pTotalAmountA / nResult;
else;
# change here what values you want to use for the calculation
nStartmonth = stringtonumber( subst (pStartdateA, 5,2));
nEndmonth = stringtonumber( subst (pTotaldateA, 5,2));
nOfMonths = nEndmonth – nStartmonth +1;
# calculate value if less than a year
nMonthAmountA = pTotalAmountA / nOfMonths;
endif;
endif;
ti23
Then enter below code as Epilog

# write variables values to txt file in servers log folder for debug
asciioutput (‘../logfiles/debuglog2.txt’, str(nStartmonth,8,2) ,numbertostring(nMonthAmountA) ,numbertostring(pTotalAmountA), numbertostring(nOfMonths));

# create a new dimension element with the date and time as value to make it uniq
sDate = (timSt(now, ‘\Y-\m-\d \h:\i’));
DimensionElementInsertDirect( sDimname,’ ‘, sDate, ‘N’ );
# update the log cube with the values
CellPutN( nStartDateA+21916, sCubename,’StartDate’, sDate );
CellPutN( pTotalAmountA, sCubename,’TotalAmount’, sDate );
CellPutN( nMonthAmountA, sCubename,’MonthAmount’, sDate );
CellPutN( nBreakDateA+21916, sCubename,’BreakDate’, sDate );

# 1 in excel is 1900, but in TM1 that is 1960 – therefor the addition of 21916 days.
ti24
Click validate, and correct any ‘ that may be of wrong format.
ti25
Save and run.
ti26
Enter your values and click OK.
ti27
Above error if there is no /logfiles/ folder parallel to the data folder.
Create on folder c:\Program Files\ibm\cognos\tm1_64\samples\tm1\logfiles, if you use a sample TM1 application that do not have a separate log folder.
ti28
Connect to the server and check the log files to see variables values.
ti29
Click on refresh for the view to see the result.
ti30

Things to review:
nBreakDateA = ParseDate( pBreakDateA, ‘yyyyMMdd’,0 );
Above code change the string to a date number, but should be changed so it is not use the 1960 as start date.

if (nStartDateA < nBreakDateA);
Above code check if the date is before a specific date, you can change this to be automatic check for 12 months .

if (nofmonths > 12);
# if total is for from start date to today – you use the same formula
nMonthAmountA = pTotalAmountA / nOfMonths;
else;
Above code check if the difference is more than 12 months, then you can enhance it to calculate the value from January to today date only, if the total is only for this year.

# asciioutput (‘../logfiles/debuglog1.txt’, str(nBreakDateA,8,2),str(nStartDateA,8,2) , numbertostring(pTotalAmountA));
Remark out the debug asciioutput lines from your code.

More information:
http://www.wimgielis.com/tm1_newdateformatter_EN.htm
https://www.exploringtm1.com/date-time-functions-tm1-10-2/
https://www.exploringtm1.com/accumulating-values-in-tm1/

Operators in TI IF Statements