Pages

Monday, March 23, 2020

Einstein Analytics: using Flatten node to get Account Parent

Here is our scenario, we have multi-level account hierarchy, the sample of accounts for this blog:



Use case 1: display all accounts and their opportunities when the top parent is selected.

Dataflow:


We need to manually edit the Flatten node from JSON, by default, the Multi Field and Path Field fields are created as system fields, which aren’t visible in the user interface. To make the fields appear in the user interface and dataflow, add a schema section to the flatten transformation and set the IsSystemField metadata attribute to false for each field in the transformation.

"Flatten_UltimateParent": {
    "schema": {
      "objects": [
        {
          "label": "Flatten_UltimateParent",
          "fields": [
            {
              "name": "UltimateParentPath",
              "label": "UltimateParentPath",
              "isSystemField": false
            },
            {
              "name": "AccountParentIds",
              "label": "AccountParentIds",
              "isSystemField": false
            }
          ]
        }
      ]
    },
    "action": "flatten",
    "parameters": {
      "include_self_id": true,
      "multi_field": "AccountParentIds",
      "path_field": "UltimateParentPath",
      "source": "getAccount",
      "self_field": "Id",
      "parent_field": "ParentId"
    }
  }


Unfortunately, we will not see the schema in the dataflow UI.

We also need to Connect Data Source between Account and Opportunity using the Ultimate Parent Name.



Here is the dashboard:



Note:

1) Multi_Field from the flatten nodes will contain self Account Id (we select "Include Self ID" in the flatten node) and all the parents' Id.

Notice that top Parent Id 0018000001BNnOPAA1 is stored in ALL hierarchy, while Account F Id only stored on itself Account F and it child Account G. Don't be trick when AccountParentIds only show 1 value, because this is a multi-values field.

2) Path_Field will show all hierarchy from self Id, up to parent Id and all the way to the top level.

* I use Image (under Show Data As) to show the full length of field content of UltimateParentPath column


Use case 2: display all accounts and their opportunities when an Account is selected, the account could be the top, middle, or lower level in the account hierarchy.

Dataflow: let us modify existing dataflow to below:



We just need to add an augment node Account Name from Multi_Field AccountParentIds.



You also need to Connect Data Source between Account and Opportunity using the Account Parent Name from the augment node.



Here is the dashboard:



When select Account F, the dashboard will filter to Account F and the child accounts.


Referenceflatten Parameters



1 comment:

  1. Thanks Johan, I was looking for the second use case, well explained thanks.

    ReplyDelete

Page-level ad