The power of static steps

5
(5)

Sometimes you want to give your end users a little bit more flexibility when viewing Wave dashboards. This could be by allowing them to choose which grouping or measure to use in the graph. Static steps are a way for you to empower this flexibility.

First, we need to create a lens we can put on our dashboard and modify with static steps. In my example I have used the measure “Sum of Amount” and the grouping “Industry”. I’ve also sorted my column graph descending. When you got your lens ready clip it into your dashboard.

StaticStepsLens

The next thing is to add the static steps in the flex designer. You can also choose to write and add the code directly in the dashboard JSON. I’ve created one for grouping, measure, limit, order and filter, which should look like this:

Now we need to add the static steps to the dashboard, I’ve chosen the toggle widget for all my static steps.

The rest of the changes will have to be done in the dashboard JSON, so preview the dashboard and enter command + e (for mac users) or control + e for (for PC users). Let’s first find the static steps for measure, group, limit, order and filter. It’s nice that the flex designer can help us create some of the logic, unfortunately I’ve found that it adds some additional characters so make sure your steps look like this:

Static measure

"StaticMeasure_1": {
 "datasets": [],
 "dimensions": [],
 "groups": [],
 "isFacet": false,
 "isGlobal": false,
 "label": "StaticMeasure",
 "numbers": [],
 "selectMode": "singlerequired",
 "strings": [],
 "type": "staticflex",
 "useGlobal": false,
 "values": [
 {
 "display": "Sum of Amount",
 "value": [
 "sum",
 "Amount"
 ]
 },
 {
 "display": "Avg of Amount",
 "value": [
 "avg",
 "Amount"
 ]
 }
 ]
 },

Static group

 "StaticGrouping_1": {
 "datasets": [],
 "dimensions": [],
 "groups": [],
 "isFacet": false,
 "isGlobal": false,
 "label": "StaticGrouping",
 "numbers": [],
 "selectMode": "singlerequired",
 "strings": [],
 "type": "staticflex",
 "useGlobal": false,
 "values": [
 {
 "display": "Opportunity Type",
 "value": "Type"
 },
 {
 "display": "Industry",
 "value": "AccountId.Industry"
 }
 ]
 },

Static limit

"StaticLimit_1": {
 "datasets": [],
 "dimensions": [],
 "groups": [],
 "isFacet": false,
 "isGlobal": false,
 "label": "StaticLimit",
 "numbers": [],
 "selectMode": "single",
 "strings": [],
 "type": "staticflex",
 "useGlobal": false,
 "values": [
 {
 "display": "3",
 "value": 3
 },
 {
 "display": "5",
 "value": 5
 },
 {
 "display": "7",
 "value": 7
 }
 ]
 },

Static order

"StaticOrder_1": {
 "datasets": [],
 "dimensions": [],
 "groups": [],
 "isFacet": false,
 "isGlobal": false,
 "label": "StaticOrder",
 "numbers": [],
 "selectMode": "single",
 "strings": [],
 "type": "staticflex",
 "useGlobal": false,
 "values": [
 {
 "display": "Ascending",
 "value": [
 -1,
 {
 "ascending": true
 }
 ]
 },
 {
 "display": "Descending",
 "value": [
 -1,
 {
 "ascending": false
 }
 ]
 }
 ]
 },

Static filter

"StaticFilter_1": {
 "datasets": [],
 "dimensions": [],
 "groups": [],
 "isFacet": true,
 "isGlobal": false,
 "label": "StaticFilter",
 "numbers": [],
 "selectMode": "single",
 "strings": [],
 "type": "staticflex",
 "useGlobal": false,
 "values": [
 {
 "display": "UK",
"value": [
 "AccountId.BillingCountry",
 [
 "United Kingdom"
 ],
 "in"
 ]
 },
 {
 "display": "Won Oppty",
"value": [
 "IsWon",
 [
 "true"
 ],
 "in"
 ]
 }
 ]
 },

To make sure that your column graph facets with your new static steps, we need to make sure they are bind together using selection binding. Find your step and in its query section make the following changes, remember to make sure the highlighted text matches the static steps you have created:

"query": {
 "measures": "{{column(StaticMeasure_1.selection, ["value"]).asObject()}}",
 "limit": "{{column(StaticLimit_1.selection, ["value"]).asObject()}}",
 "groups": "{{column(StaticGrouping_1.selection, ["value"]).asObject()}}",
 "filters": "{{column(StaticFilter_1.selection, ["value"]).asObject()}}",
 "order": "{{column(StaticOrder_1.selection, ["value"]).asObject()}}"
 },

This should make the whole step look like this:

"StepSales_1": {
 "datasets": [
 {
 "id": "0Fb58000000CeCnCAK",
 "label": "Opportunity with Account and Campaign",
 "name": "Opportunity_with_Account_and_Campaign",
 "url": "/services/data/v39.0/wave/datasets/0Fb58000000CeCnCAK"
 }
 ],
 "isFacet": true,
 "isGlobal": false,
 "label": "StepSales",
 "query": {
 "measures": "{{column(StaticMeasure_1.selection, ["value"]).asObject()}}",
 "limit": "{{column(StaticLimit_1.selection, ["value"]).asObject()}}",
 "groups": "{{column(StaticGrouping_1.selection, ["value"]).asObject()}}",
 "filters": "{{column(StaticFilter_1.selection, ["value"]).asObject()}}",
 "order": "{{column(StaticOrder_1.selection, ["value"]).asObject()}}"
 },
 "selectMode": "single",
 "type": "aggregateflex",
 "useGlobal": true,
 "visualizationParameters": {
 "visualizationType": "vbar",
 "options": {}
 }
 }

Now preview and save your dashboard. That’s all you need to do in order to use static steps to make your dashboards even more flexible.

**Update – in the Spring 18 release Salesforce introduced a new parameter ‘columnMap’, which means the bindings described in this blog will throw an error unless the ‘columnMap’ is adjusted as described in this blog**

**Update – in Winter 20 static steps was renames to custom query and got a new user interface, check out my blog on custom queries**

How useful was this post?

Click on a star to rate useful the post is!

Written by


8 thoughts on “The power of static steps”

  • 1
    Valentin on May 22, 2017 Reply

    Hi,

    Thanks for this really great post ! do you know if there’s a way to use a static step to manage some true/false parameters ?
    I’m trying to use a static step to define if a chart should be normalize “true” or “false” but for the moment the code bellow doesn’t work :

    “chart_1”: {
    “parameters”: {
    “autoFitMode”: “keepLabels”,
    “showValues”: true,
    “legend”: {
    “showHeader”: false,
    “show”: true,
    “customSize”: “auto”,
    “position”: “right-top”,
    “inside”: false

    },
    “normalize”: “{{column(Normalize_ou_value_1.selection, [\”value\”]).asObject()}}”,

    “satic_step”: {
    “Normalize_ou_value_1”: {
    “type”: “staticflex”,
    “values”: [
    {
    “display”: “Normalisé”,
    “value”: true
    },
    {
    “display”: “Valeur”,
    “value”: false
    }
    ],

    • 2
      Rikke on June 5, 2017 Reply

      Hi,

      Looking at the code the normalize should be inside the {}, also it seems that some of the parameters are missing from the chart. Now the statement should be something like this: “normalize”: “{{cell(Normalize_ou_value_1.selection, 0, \”value\”).asString()}}”. However, I’ve found that even though the documentation says you can bind widgets to static steps, it is only maps that currently accepts a string value.

      Cheers

  • 3
    Surbhi on April 12, 2018 Reply

    Hi,

    A big thanks for this post. it solved so many doubts i had.
    i am trying to put value with certain condition in my static step and group the chart with this static step.
    but i am getting this error :This widget can’t be displayed because there is a problem with its source step:a.replace is not a function.
    except this two display-value pair others are working fine.PFB static step code
    “staticstep_1”: {
    “broadcastFacet”: true,
    “groups”: [],
    “label”: “staticstep”,
    “numbers”: [],
    “selectMode”: “singlerequired”,
    “start”: {
    “display”: [
    “Order Finalized Year”
    ]
    },
    “strings”: [],
    “type”: “staticflex”,
    “values”: [
    {
    “display”: “Without Forms”,
    “value”: [
    “Number_of_Forms__c”,
    [
    [
    0
    ]
    ],
    “==”
    ]
    },
    {
    “display”: “Status assigned”,
    “value”: [
    “Status__c”,
    [
    “Assigned”
    ],
    “in”
    ]
    }]
    and Grouping :
    “groups”: [
    “{{column(staticstep_1.selection,[\”value\”]).asObject()}}”
    ],

    • 4
      Rikke on April 12, 2018 Reply

      It looks to me like you are passing filters as a grouping, that won’t work. You have to split it out in two if it is meant to be a grouping. Your group and your filter condition separately. You can have two values in your step, just call them value1 and value2 and remember to call the correct one in the binding.

  • 5
    Santi on October 26, 2018 Reply

    Hi Rikke,
    Thanks for this great post that solves a lot of doubts I had. I’m new in Wave Dashboards and I’m stuck and frustrated in the creation of a dashboard. I have a number widget that counts Accounts. I bind a static step in order to filter them as you explain in the post and it works perfectly. Now I want to add another toggle to filter again the same number widget but you get the data from a cogroup of two datasets. How can I apply the Id result of the cogroup to the number widget?

    Thank you so much!

  • 6
    Shiulee Chakraborty on June 6, 2019 Reply

    Hi Rikki,

    Your blogs are really helpful. I have a doubt. I am following the same steps what you have given for order sorting. I am applying binding to the saql editing compare table and below is my code:

    “lens_3”: {
    “broadcastFacet”: true,
    “groups”: [],
    “label”: “lens_3”,
    “numbers”: [],
    “query”: “q = load \”LITMOS_DATA\”;\nq = group q by ‘Litmos.Name’;\nq1 = load \”ANSWER\”;\nq1 = filter q1 by ‘GetFeedback_Aut__Number__c’ > 0;\nq3 = load \”RESPONSE\”;\nq3 = filter q3 by ‘Survey_Sent__c’ == \”true\”;\nq2 = cogroup q by ‘Litmos.Name’ left, q1 by ‘Answer.Litmos__Full_Name__c’full, q3 by ‘Litmos.Litmos__Full_Name__c’;\nq2 = foreach q2 generate q.’Litmos.Name’ as ‘Contact Name’, avg(q.’Litmos__PercentageComplete__c’) as ‘Percentage Complete’, avg(q.’Litmos.pi__score__c’) as ‘Pardot Score’, avg(q1.’GetFeedback_Aut__Number__c’) as ‘Average Survey Score’, count(q3) as ‘A’, unique(q3.’response.GetFeedback_Aut__Contact__c’) as ‘unique_respons’;\nq4 = foreach q2 generate ‘Contact Name’, ‘Percentage Complete’,(unique_respons/A)*100 as ‘Survey Completed’,’Average Survey Score’,’Pardot Score’; \nq4 = order q4 by {{column(Order_1.selection, [\”value\”]).asObject()}};\nq4 = limit q4 10000;\n\n”,
    “receiveFacet”: true,

    I am getting error:
    This widget can’t be displayed because there is a problem with its source step:
    Syntax Error at position [line 10: column 19] after token ; :: order q4 by ; q4 = limit q4

  • 7
    joe on July 31, 2019 Reply

    Hi Rikki,
    Thanks for such a great post. when creating a static step, is it possible to initialize one of values based on a soql step for current logged-in user? my example code snippet is as blow. However, when binds the section to other chart filtering. below ‘Regional’ selection is not working, ‘Global’ section works though. Much appreciated if you can help out.

    “values”: [
    {
    “display”: “Region”,
    “value”: [
    “Region__c”,
    [
    “{{cell(UserData.result, 0, \”Region__c\”).asString()}}”
    ],
    “in”
    ]
    },

    ,
    {
    “display”: “Global”,
    “value”: [
    “Region__c”,
    [ “US”, “Canada”, “Europe” ], “in”
    ]
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.