A Template for Date Calculations in Tableau

The most common calculations I make in Tableau are date-related. I’ve made hundreds of them with variations for year-over-year, month-over-month, rolling date ranges and a long list of customizations. Some of our most popular blog posts at InterWorks are those teaching people how to handle this kind of date math. Frankly, a need this common should be easier. Well, now it is!

The template described below contains common date-based options and calculations. It simplifies your workflow, letting you cut and paste all the logic you need. Customizing those options takes a few simple steps.

Using the Template

  1. Download it from Tableau Public (which may be updated periodically), or click on the file at the bottom of this post.
  2. Open the workbook in Tableau Desktop, and start on the tab named Date Logic Template.
  3. Read the procedures there, then click Go to Worksheet to access the data source with the calculations you need. This worksheet also lets you inspect the result of each calculation and parameter option day by day.
  4. To further understand the options and how to use them, click through the tabs for detailed logic explanations and instructions on building the example visualizations.

Performance Considerations

Astute observers will see that this template uses a lot of parameter-based row-level calculations. These can negatively affect performance, especially on larger datasets. If you experience poor response times with your data, you can remove the parameter references and create separate calculations specific to each time range. That approach lets you materialize the calculation result in a Tableau extract.

Further Reference

For more in-depth explanation and variations on date calculations, see these posts:

If none of these resources speak to your specific need, we’re here to help! Contact our experts for customized support.

Download the Template

The post A Template for Date Calculations in Tableau appeared first on InterWorks.

InterWorks

Przemysław Kołodziejczyk: Python 3 – Template strings instead of external template engine

I don’t know about you, but there is only one thing where I use templates on the backend side. Emails. Usually, when people need to render HTML template, they install Jinja2 or other template engines. The case is that it’s not always required. If you have a template where you need to put some data, you don’t need an external template engine. When you need to do something with this data, you don’t need to do that inside a template using Jinja2 filters.
Planet Python

Creating an Enterprise Template

custom enterprise template in Tableau

At many organizations, Tableau opens the door for creativity that didn’t exist before. Often, it’s awesome because folks get to see and understand their data. However, sometimes, our marketing and communications department would probably prefer some major dashboard components stick to brand (I’m looking at you, five-years-ago self, and your rainbow dashboard … because who doesn’t love color).

So, organized people that we are, when it comes to creating a dashboard, we set up a meeting with our communications team and get their sign-off on the color schemes and use of the company logo. We drop them on a dashboard, and we’d like to get everyone in the company to use this set-up.

Previously, I’ve seen companies share this new “template” on a platform like Box or a shared drive, and then when folks go through Tableau training, they’re given access to this secret folder and can download it.

Building a Dashboard from the Ground up

Now, while this in theory is a good idea, let me give you scenarios that I’m all too familiar with from personal experience:

  • I open the template workbook, build what I want, publish and press Save As. Now my template is no longer a template. If I want to use it again, I then need to go back to my Shared Folder and re-download.
  • Err … where did that file exist? Let me call someone and see if they can find it.

I cycled between these two options for the first dozen dashboards I built. Then one day, when I was feeling especially impatient:

  • Eh, I’m just going to mock something up really quick. I don’t want to go look for that template wherever it is. I’ll just start blank.

And so, good intentions quickly tumble into inconvenience and bad habits. So, how can we make this easier? Well, when you open Tableau, notice that there are Sample Workbooks on the homepage:

sample workbook templates in Tableau

What if I could make my template a sample workbook, so it would just always be available to everyone?
Well … you can!

How to Create Your Dashboard Template

While anyone with Admin access to their computer can do this, if you want this to be default when anyone in your organization downloads Tableau and not have individuals manage it, you’ll need to work with your IT team to ensure the Program Files discussed in this post are customized for your template.

Now, let’s get going. First, where do these sample workbooks live? On your computer, find Program Files and navigate to Tableau > your version help > Workbooks > your language:

creating a template for Tableau

Now, the sample workbooks have several components to them, but the two you’ll definitely want are the workbook template saved as a .twbx and a .png image of that workbook, so your users can see what it looks like on the home page. Paste both of these items in the folder. This is the first place you’ll want to make sure you have admin access—when you go to paste, you’ll likely get an error similar to this:

creating a template for Tableau

Go ahead and click Continue and either use Admin credentials or contact your helpdesk. Make sure to keep them on the phone because you’re going to need them again in just a minute.

Editing the Manifest File

All right, so we’ve added “Template. twbx” and “templatescreenshot.png” to our en_US Workbooks folder, but now we also need to edit the manifest file so Tableau knows to pull them in. If you’re asking, “What’s a manifest file?!”, check out Debbie Yu’s blog post where she answers that.

In the folder, you’ll see a file called samples.manifest. Right-click on that, and choose to open in a text-editing program; I’m using Notepad++:

text-editing when creating Tableau dashboard template

When you open it, you’ll notice it’s Read-Only. If you right-click on the title, you’ll see the option to Clear Read-Only Flag (again, this is where you’ll likely get prompted to enter Admin credentials and reasonably so because these manifest files are important to programs running):

text-editing when creating Tableau dashboard template

So, with the flag cleared, you’ll want to add a fourth line to this manifest file, with the name of your .twbx template and thumbnail .png image:

adding your details to a manifest file

You can change the thumbnail format and count if you’d like as well, but for now, I’m keeping them the same as the World Indicators. Go ahead and save this. Be careful because if you Save As, it will try to save it as an .XML file, and you’ll want to make sure you’re saving to overwrite the current samples.manifest file. You may get one more error telling you the file can’t save. If so, reopen the program in Administrator mode and it will let you save:

administrator mode when creating a dashboard template

Whew! Now for our reward:

custom enterprise template in Tableau

No more chasing down that pesky template in shared drives. It’s there by default for me all the time. Comms team celebration!

Across the organization, if your IT time can change this manifest file and add in this .twbx and .png to their standard Program Files in the installation package, everyone in your organization with Tableau will automatically have your template!

The post Creating an Enterprise Template appeared first on InterWorks.

InterWorks