Pages

Monday, May 14, 2018

Einstein Analytics: The quest for Binding in Dashboard

This blog is written in Summer '18 release, so this blog may become invalid when Salesforce makes "binding" become more user-friendly in the future.

Until Summer '18 release, if you would like to implement binding in the dashboard using Toggle, you need to edit the dashboard JSON.

Use case: you would like to give user flexibility to change chart grouping, example: group by Region, or by Country, or by Status. Another use case, the user would like yo have the flexibility to change chart type without the need to edit the dashboard, or would like to implement both in the same dashboard, this makes sense, when you change grouping, the chart type probably needs to change for better visualization.

This blog will not share on how to create binding or static with toggle, you can watch the awesome Peter Lyon's videos Binding Basic, and Rikke Hovgaard's blog The power of static steps.

In this sample, I have 2 charts and 2 toggles.



This is how the dashboard looks.

please ignore 2 charts display the same result


I am going to edit the JSON with Ctrl-E

Binding group by Field Name
- change "query" in "groups" under "steps"
  "{{coalesce(cell(static_1.selection, 0, \"value\"), cell(static_1.result, 0, \"value\")).asString()}}"
   when "View" the dashboard, if selected field in toggle different with the field use for initial grouping, it will show error in chart


- change columnMap under "widgets" or "chart" to
   "columnMap": null OR delete the whole columnMap

Binding group by Chart Type
- change columnMap under "chart" or "widgets"  
   "columnMap": null OR delete the whole columnMap
- change "visualizationType" under "parameters" in "widgets" or "chart"       
"{{coalesce(cell(static_2.selection, 0, \"value\"), cell(static_1.result, 0, \"value\")).asString()}}" 

please ignore 2 charts display the same result


Binding table
We also can use a toggle to sort header table, on the addition of out of the box sort function. JSON below only applicable when the SAQL is not edited. Here is the JSON snippet from steps:
  "query": {  
           "values": [  
             "Company_Name__c",  
             "Country__c",  
             "Region__c",  
             "Status__c"  
           ],  
           "order": [  
             [  
               "{{ value(selection(static_3)) }}",  
               {  
                 "ascending": "{{ value(selection(static_4)) }}"  
               }  
             ]  
           ]  
         }  

This is the JSON step for the fields selection:
      "static_3": {  
         "broadcastFacet": true,  
         "label": "static 3",  
         "selectMode": "singlerequired",  
         "type": "staticflex",  
         "values": [  
           {  
             "display": "Company Name",  
             "value": "Company_Name__c"  
           },  
           {  
             "display": "Status",  
             "value": "Status__c"  
           },  
           {  
             "display": "Country",  
             "value": "Country__c"  
           },  
           {  
             "display": "Region",  
             "value": "Region__c"  
           }  
         ]  
       }  

This is the JSON step for the fields order:
     "static_4": {  
         "type": "staticflex",  
         "broadcastFacet": true,  
         "selectMode": "singlerequired",  
         "label": "static 4",  
         "values": [  
           {  
             "display": "Asc",  
             "value": true  
           },  
           {  
             "display": "Desc",  
             "value": false  
           }  
         ]  
       }  
** notice that order should not in the double quote ""


Here is the full JSON for the dashboard.