Pages

Thursday, December 6, 2018

Einstein Analytics: Filter Dataset across Object

Use Case:
To produce a clean dataset in dataflow based on the following scenario:
There are 2 objects in SFDC which is not directly related, but both have Opportunity Id.
- Result OS = digest object OS with some filters, contain Opportunity Id.
- Result A = digest object A with some filters, also contain Opportunity Id.
- Result OS should only contain records where Opportunity Id available in Result A.

Solution:
  • Start from Result OS
  • Do augment with the Result A
  • Create compute expression node -- case when ('OppId' is not null && 'OppId' == 'resultA.OppId' then "Yes" else "No" end 
  • Finally, create filter node to filter "Yes"

Dataflow:


JSON (simplified)
 {  
  "getOS": {  
   "action": "edgemart",  
   "parameters": {  
    "alias": "dataOS"  
   }  
  },  
  "getA": {  
   "action": "edgemart",  
   "parameters": {  
    "alias": "dataA"  
   }  
  },  
  "augOS_A": {  
   "action": "augment",  
   "parameters": {  
    "operation": "LookupSingleValue",  
    "relationship": "A",  
    "left": "getOS",  
    "left_key": [  
     "OptyId"  
    ],  
    "right": "getA",  
    "right_key": [  
     "OptyId"  
    ],  
    "right_select": [  
     "AccId",  
     "Name"  
    ]  
   }  
  },  
  "Check_in_A": {  
   "action": "computeExpression",  
   "parameters": {  
    "mergeWithSource": true,  
    "source": "augOS_A",  
    "computedFields": [  
     {  
      "type": "Text",  
      "name": "Found",  
      "label": "Found",  
      "saqlExpression": "case when 'A.Name' is not null then \"Yes\" else \"No\" end"  
     }  
    ]  
   }  
  },  
  "regFilter": {  
   "action": "sfdcRegister",  
   "parameters": {  
    "alias": "Filter1",  
    "source": "Filter_Only_Yes",  
    "name": "Filter1"  
   }  
  },  
  "Filter_Only_Yes": {  
   "action": "filter",  
   "parameters": {  
    "filter": "Found:EQ:Yes",  
    "source": "Check_in_A"  
   }  
  }  
 }  


No comments:

Post a Comment