The Ultimate Transitioning to Bindings 2.0 from Bindings 1.0 Guide.

This post inspired by and a large nod to Robert Houston whose nickname in our ecosystem is The Wolf. Most likely the best technical person on our platform. The Wolf recently wrote a piece I saw comparing Bindings 1.0 and Bindings 2.0 - this post is a view of this for the community. The idea of this post is to show all steps needed to build a full dashboard in Bindings 2.0 then show a comparison of Bindings 1.0 and Bindings 2.0 in a Copy/Paste scenario for reference.

When the Bindings 2.0 came out there was a lot of feedback from customers , partners and SE’s. Bindings 2.0 is hard….. why did we change ?

  • To secure Bindings 2.0, we wrote our own grammar and secure execution engine that would also be nicely shared across platforms, bringing parity to mobile and desktop.
  • So no matter where the binding was used nor the type or shape of step that was bound, the same data in would produce the same results out.
  • Bindings can be placed outside of a Step
  • debug-ability. We can tell you exactly where your syntax is wrong and exactly where in the execution the binding broke.*
  • full row emits

So we have the why :) lets figure out the how..

First thing to do is check out the Bindings 2.0 documentation which can be found here Bindings 2.0 Documentation

Below we will now show the steps needed to show each of the binding functions. We have a number of steps per scenario and a full Dashboard JSON for review.

First step generates a graph with a gouping of Carrier. All of the steps have broken down individually. All of the items below use the OnTime dataset.

The below step is a DateSelector step

Static Measure Step - This step allows you to have fixed values and pass them through to other steps. 

Destination_1 is a compact step, that groups the results by Carrier in the OnTime Dataset

Destination_SAQL is the same as Desintation_1 however the step is built in SAQL

The below code is a full snippet of the Dashboard build including all of the above steps. The dashboard is called "Bindings 2.0 Test"

 
Screen Shot 2016-11-19 at 10.37.49 PM.png
 

Using the below table we can see the older Bindings 1.0 version of bindings and compare them to the new Bindings 2.0. Hopefully you will be able to simply copy and paste the examples..

Bindings 2.0

Bindings 1.0


Anything where you are selecting 1-n values from a single dimension e.g. a list selector, pillbox or chart.


Compact example: Destination_1 line 28

"filters": [
    [
"field",
      "{{selection(step)}}
    ]
]
"filters": [
    [
"field",
"{{column(step.selection,
[\"DestField\"]).asObject()}}" 
    ]
]

SAQL example: Destination_SAQL line 8

q = filter q by 'field' in 
{{selection(step)}};
q = filter q by {{column(step.selection,
  [\"DestField\"]).asEquality(\"field\")}}; 
  

q = filter q by 'field' in 
{{coalesce(column(step.selection, [\"DestField\"]),
\"all\").asString()}};

Anything where you are selecting a single value from a single dimension e.g. a list selector, pillbox or chart.


"filters": [
    [
"field",
      "{{selection(step)}}
    ]
]
"filters": [
    [
"OwnerName",
"{{cell(step.selection, 0, 
\"DestinationField\").asObject()}}"
]
]
q = filter q by 'field' == {{selection(step)}};
q = filter q by {{cell(step.selection, 0,
  \"DesinationField\").asEquality(\"field\")}};
OR
q = filter q by 'field' == \"{{cell(step.selection,
  0, \"DesinationField\").asString()}}\";
OR
q = filter q by 'field' == \"{{cell(step.selection,
  0, \"DesinationField\").asObject()}}\";
  
Note: Only asEquality() handles nothing being 
  selected or “all” case well so recommended
  best practice is to use the previous example 
  of selecting 1-n values instead.

Any Date selector Widget:


Compact Example: Destination_1 line 21

"filters": [
[
"datefield", "{{selection(datewidgetstep)}}
]
]
"filters": [
    "datefield",
    [
"{{row(datewidgetstep.selection, 
[0], [\"min\", \"max\"]).asObject()}}" ],
">=<="]
]
 

"Note: you can use “in” instead of “>=<="

SAQL example: Destination_SAQL line 8

q = filter q by date('datefield_Year', 
'datefield_Month', 'datefield_Day') 
in {{selection(datewidgetstep)}};
q = filter q by {{row(step, [0], [\"min\",
  \"max\"]).asDateRange(\"date('datefield_Year', 
  'datefield_Month', 'datefield_Day')\")}};

Static step with custom date ranges


Compact example: Destination_1 line 14

Static step value: "compact_step_value": "[[[\"day\",-30],
[\"day\",-1]]]",

"filters": [
  [
    "datefield",
"{{no_quote(value(field(selection(staticstep),
'compact_step_value')))}}" ]
]
Static step value: "compact_step_value": [["day",-30],
["day",-1]],

"filters": [
  [
    "datefield",
    [
"{{cell(staticstep.selection, 0, \"compact_step_value\")
.asObject()}}" ],
"in" ],
]

SAQL example: Destination_SAQL line 8

Static step value: "saql_step_value": "[\30 days ago\"..
\"1 day ago\"]"

q = filter q by date ('datefield_Year', 
'datefield_Month', 'datefield_Day') in
{{no_quote(value(field(selection(staticstep),
  'saql_step_value')))}};
Static step value: "saql_step_value": ["30 days ago", "1 day ago"]

q = filter q by {{cell(staticstep.selection, 0,
  \"saql_step_value\").asDateRange
  (\"date('datefield_Year', 'datefield_Month', 
  'datefield_Day')\")}};

Anything Static step with custom measures ( syntax also works for groups )


Compact & SAQL example the same:  Destination_SAQL line 12 , Destination_1 line 27

Static step value: "measure": [["sum","measure"]]

"measure": "{{(value(field(selection(staticstep),
'measure')))}}",
Static step value: "measure": ["sum","measure"],

"measure": "{{column(staticstep.selection,
[\"measure\"]).asObject()}}",