Enhancing Visualization in Einstein Analytics

At SpringML, we use Einstein Analytics to build standard and custom Key Performance Indicators (KPI’s) visualizations for our clients.  Analytics Studio Application has a built-in method of adding horizontal reference lines much like the red line seen with ‘Budget’(see Figure 1a) however visualizations sometimes need an additional line that functions on an equation (see Figure 1b).  The Reference Line settings do not allow equations to be entered, only simple values. This blog post will demonstrate one way the value of a Reference Line in Einstein Analytics can be modified to an equation and placed on the dashboard of a visualization.

Figure-1a
Figure 1a. Shows the Reference Line as only a value.
Figure1b-1c
Figure 1b. Shows the ‘BUDGET’ and the first step of the process to add an equation to the Reference Line ‘RIGHTHERE’

Method

A custom equation can be added to a visual using the following methodology.  For this example, a ‘Running Average’ of all data point values were used to create the YTD AVERAGE reference line. For clarity, the red reference line, labeled BUDGET has only a single value.  The blue line is the custom line that uses a running average labeled as YTD AVERAGE.  Follow these steps:

  • Create a lens as you normally do with the dataset.
  • Figure 2
    Figure 2. Addition of reference lines under formatting, where red is a value and blue will be an equation.

    The standard (red) reference line, BUDGET, was added using the Reference Lines and choosing the appropriate value (see Figure 2).

  • To start building your custom reference line using the Running Average equation (blue), add an additional reference line RIGHTHERE. RIGHTHERE will replace in later steps.  The placeholder is easier to view within the lens if you choose a value not equal to zero.
  • To add an equation, such as running average year to date:
  1. First add the equation using –Table Mode-> Compare Table–> Use formula
    Figure-3
    Formula: avg(‘Name of Column you are averaging’) over([..] partition by ‘all’)
  2. Figure 4.
    Figure 4. Changing names of the ‘Column Alias’ and ‘Column Header’. In SAQL, this will look like: “over([..] partition by ‘all’) as ‘Average’;”
    Change “Column Header” to something useful such as Average or Running Average (see Figure 4).
  3. Change the “Column Alias” to something like Average or Running_Average.
  4. Save your lens
  5. Create a dashboard.
  6. Clip the Clip lens and it will pop up under ‘Create Step’ on the Dashboard designer. Give the clip the name AVERAGE.  It will show on the Dashboard under ID as AVERAGE_1. This will be the name used in the JSON “value” equation.Clip to Designer
  7. Both reference lines will be visible once you drag the new step to the dashboard.

    Figure 5
    Figure 5
  8. Use Command E to go to the JSON file. Command F will allow you to do a search and find the text you used as a marker (RIGHTHERE) to change into an equation. In this example, the ‘Running Average’ equation created within the lens. Search for the marker which will be found next to “label” (see Figure 6). You can replace the ‘RIGHTHERE’ with any label, the example uses ‘YTD AVERAGE’.

    Figure 6
    Figure 6: Sample Visual
  9. On the JSON line starting with (“value”:), you will want to include a script for the equation needed. The Column Alias in the original lens, in this case, we used ‘Average’.
  10. Wherever you placed the marker value in the lens is the number that will appear next to “value”. In Figure 6, we put REFERENCE LINE # but 5,200,000 was the actual value places in the Reference Line tool within the original lens. Replace the “value” with the equation used in the original lens. In this case, we used a Running Average, so the value is:
    “value”: “{{cell(AVERAGE_1.result, 0, \”Average\”).asString()}}”Where, AVERAGE_1 is the clipped step ID name of the lens inserted into the dashboard and “Average” is the Column Alias name given to the equation within the lens.
    NOTE:
    appears twice in the JSON file to make sure the changes are made change both. (Simple copy and paste works!)
  11. Save your JSON.
  12. Go back to the visual and make any necessary changes.
  13. The final visual in EA will look something below where you have the ‘YTD AVERAGE’, as the running average equation, and the ‘BUDGET’ as a simple value both involving the Reference Line.

    Figure 7
    Figure 7

Conclusion

This is one of many modifications SpringML is capable of solving when building KPI’s for a client using Einstein Analytics. We enjoy the challenge and always do our best to find solutions outside of the standard application for our clients.