New Upload weather data from web services into TM1/Planning Analytics — Read the post →

Connecting Salesforce to TM1

IBM Planning Analytics (TM1) developers benefit from TM1py, in particular when source data resides in cloud systems such as Snowflake or Salesforce, where it can't be reached easily with plain TM1.

Three ways to connect Salesforce with TM1 programmatically

Options 1 and 2 require two steps: one Python script to extract Salesforce data to a relational database or CSV files, and one TM1 process to load the data. The third option requires only one Python script — this is the only one that works with both TM1 on-premise and IBM Planning Analytics Cloud.

The Python script

Three main sections: connect to Salesforce and request data, transform the data and create a dimension object in Python, then create this dimension in TM1.

1. Requesting data from Salesforce

Using the simple_salesforce Python package, connect with one line:

Write a SOQL query to retrieve data. You can use dataloader.io to help build queries:

2. Transforming the data

A TM1py dimension object requires: list of elements, list of edges (parent/child), list of attributes, and attribute values.

Create a new hierarchy, loop through the fields to create attributes, add the total consolidation, then loop through records to create edges and attribute values:

3. Sending data into TM1

Only three TM1py functions needed: TM1Service to connect, dimension.update_or_create to create the dimension, and cubes.cells.write to update attributes — all with only 3 lines of code: