Winter ’17 – Salesforce Analytics – Bindings

winter17

Salesforce Analytics uses the concept of Bindings to interact with steps in the dashboard. Winter 17 Release is coming up with significant changes to usage of Bindings.

Quick Primer on Classic Designer.

A lens in Wave dashboard comprises of a step and widget.

Step – Step has the details of how the data is represented – dataset to query, filter conditions, group by etc.

Sample JSON

 "ProviderName_7": {
 "isFacet": true,
 "isGlobal": false,
 "query": {
 "measures": [
 [
 "sum",
 "TRx"
 ]
 ],
 "groups": [
 "ProviderName"
 ]
 },
 "selectMode": "multi",
 "start": [],
 <strong>"type": "aggregate",</strong>
 "useGlobal": true,
 "datasets": [
 {
 "name": "PharmaSales"
 }
 ],
 "visualizationParameters": {
 "visualizationType": "hbar"
 }
 },

Note the usage of type aggregate.

Widget – Widget section has the details of the UI coordinates

 "dimfilter_2": {
 "type": "listselector",
 "position": {
 "h": 50,
 "w": 260,
 "x": 10,
 "y": 180,
 "zIndex": 100002
 },
 "parameters": {
 "expanded": false,
 "step": "ProviderName_7",
 "title": "Doctor Name",
 "selectModeOverride": "multi"
 }
 }

Highlights of Binding changes

  1. No zIndex – No more bandages and hiding parts of lens. Most of Step and Widget properties can now be configured in Dashboard designer itself.
  2. Selection and Results Bindings use the same syntax – e.g  <stepName>.<result|selection>
  3. Bindings can now be applied to widget properties as well!

Migrating to Flex Designer

As a first step, dashboards built using classic designer need to be opened using Wave Dashboard Designer (In beta phase it was called as flex designer)

2016-09-30_1148

Most of the step configurations should work with few caveats. For more information on changes refer to documentation

Step JSON

"all_1": {
 <strong>"type": "aggregateflex",</strong>
 "visualizationParameters": {
 "visualizationType": "hbar",
 "options": {}
 },
 "query": {
 "measures": [
 [
 "count",
 "*"
 ]
 ]
 },
 <strong>"datasets": [</strong>
<strong> {</strong>
<strong> "name": "PharmaSales",</strong>
<strong> "url": "/services/data/v38.0/wave/datasets/0FbB000000007mpKAA",</strong>
<strong> "id": "0FbB000000007mpKAA"</strong>
<strong> }</strong>
 ],
 "isFacet": true,
 "isGlobal": false,
 "useGlobal": true
 },

Note changes to type is now referred as aggregateflex and more details on dataset.

Widget JSON – Changes here are significant.

Depending on the charts the attributes added to widget section varies.

 "chart_1": {
 "type": "chart",
 "parameters": {
 "visualizationType": "hbar",
 "title": {
 "label": "",
 "subtitleLabel": "",
 "align": "center"
 },
 "theme": "wave",
 "showValues": true,
 "axisMode": "multi",
 "autoFitMode": "fit",
 "dimensionAxis": {
 "showAxis": true,
 "showTitle": true,
 "title": ""
 },
 "measureAxis1": {
 "showAxis": true,
 "showTitle": true,
 "title": "",
 "referenceLine": null
 },
 "measureAxis2": {
 "showAxis": true,
 "showTitle": true,
 "title": "",
 "referenceLine": null
 },
 "legend": {
 "show": true,
 "showHeader": true,
 "inside": false,
 "position": "right-top"
 },
 "trellis": {
 "enable": false,
 "type": "x",
 "chartsPerLine": 4
 },
 "exploreLink": true,
 "step": "all_1"
 }
 },

Syntax Changes

In the classic designer we were limited to using {{selection()}} and {{results()}} syntax to retrieve a single value, array or a row. With the new syntax its lot more structured and gives control to developers on how to interact with steps.

At a high level, selection or results can be accessed as Cell, Row or a Column

  • Cell – cell(source), rowIndex, columnName)
  • Column – column(source), [columnNames…])
  • Row – row(source), [rowIndices…], [columnNames…])

Additional Functions

This is where the fun part is, once the data is accessed we can now perform functions to manipulate data and more importantly have features to make it SAQL compatible.

Data Manipulation

Functions like coalesce, concat can now be applied easily to bindings.

Data Serialization

Serialization functions like asDateRange(), asEquality(), asRange() provides SAQL equivalent. This is a huge productivity booster for developers to quickly generate SAQL code.

Sample data serialization applied to widget attribute.

"number_6": 
{ "type": "number", 
"parameters": {
 "step": "color_2", 
"measureField": "count", 
"textAlignment": "right", 
"compact": false, 
"exploreLink": true, 
"titleColor": "#335779", 
"titleSize": 14, 
<strong>"numberColor": "{{cell(color_2.result, 0, \"color\").asString()}}",</strong> 
"numberSize": 32, 
"title": "Opp Count (Asia Pacific)" 
} },

Note number color is tied to results binding.