In April I did a blog on how to use date fields in static steps showing how to create filters and groupings [read the blog post]. Though the blog is still relevant I had several people comment that it didn’t work. I did a little debugging and it turns out that Einstein Analytics is a little particular in terms of how the JSON instructions should be written. And in one of the releases after I wrote the original blog they have added a “feature” where the one JSON line you add while creating your step is no longer converting it into the correct format.
Anyway, let’s see if we can’t shave down the many lost hours on this.
Why isn’t it working?
As I mentioned above the static step builder is adding a little extra when you add your string. So in my blog I wrote to add the following:
What you will find is you get an error like this:
Now, why is that? If we look behind the scenes in the dashboard JSON you will see this:
As you may notice in line 319, we are getting a few more characters than what we actually put in creating the static step. Instead, we need something like line 323 to line 327.
How do we fix it?
Well, we can either try to remove the unwanted characters or copy from another lens and paste them into the dashboard JSON if you are worried about removing the right characters. Be aware that I have experienced a few cases where it still didn’t work even though I removed the right characters, but the copy/paste fix did the trick instead.
Start by creating your static step as described in the original blog. Click “Create Step” then choose “Create a Static Step with Custom Values”.
Give your step a name and add your values. Keep your display as you want the user to see but just put “Placeholder” as your value. Finally, click “Create”.
Now you have your new step we need to modify it. First, open up a lens from the dataset you are using in your dashboard and do a grouping by your date field (Year-Month). In my case, it will be Close Date (Year-Month).
Now go to your lens JSON (command+e or control+e), find your grouping and copy it. Remember I am only interested in line 16 to 19.
With that copied go back to your dashboard and switch to JSON mode (command+e or control+e). Find your static step. I normally use the command+f or control+f function, put in my step name and search for it. In this case, you can also search for the word “Placeholder”. It’s just the quickest way to find anything in the JSON.
When you have the right step in front of you we now want to replace “Placeholder” including the quote signs with the grouping we just copied from the lens. Be aware you choose the right Placeholder to replace. We want the Year-Month as that matches our grouping.
Now follow the steps above for the Year-Month-Day grouping.
When done make sure that your selection binding for the grouping is updated to use this step. If you are unsure about this go back to the original blog and follow the steps.
Now go back to your dashboard designer. We need to make sure the toggle is using your new static step. So remove the step from your existing date toggle (if you have one of course else create a new one). Drag the new static step into your toggle and preview your dashboard. Note that you may want to pick an initial filter by clicking the three dots in the top right corner, else your chart won’t have a grouping to begin with.
That’s the fix – I hope you get it working now.