Using #Tableau Buckets To Compare Weekday To Weekend Data

Introduction

Whether I’m exploring personal or work-related data, I frequently use a technique that I call “creating Tableau Buckets”.

Whenever I have to group items together in some fashion, I usually just create a bucket with a calculated field.  I have written a few blog posts about different types of buckets in the past, but this weekend I created a new type of bucket that you might find useful. I call this the “Weekend vs Weekday” bucket.  As you might guess from the name of the bucket, this will place data that occurred on Sat/Sun in the “Weekend” bucket and Mon-Fri data in the “Weekday” bucket.   This is accomplished with a simple formulation  that is shown below, followed by a short video showing its usage.


If you like this article and would like to see more of what I write, please subscribe to my blog by taking 5 seconds to enter your email address below. It is free and it motivates me to continue writing, so thanks!

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.


The Formula

Given any data that has a date field connected to it, you can place the data into the “Weekend or Weekday” bucket by using this formula:

// Weekend or Weekday Bucket, Ken Black, November 18, 2013
// This bucket is used to aggregate items based on the day of the week.
// If the item occurred on Sat/Sun, it goes into the Weekend bucket.
// If the item occurred on Mon-Fri, it goes into the Weekday bucket.
//
// Simple and clean if then else structure using Datepart command.
//
if(DATEPart('weekday',[Date])=1) then 'Weekend' //Sunday
elseif(DATEPart('weekday',[Date])=2) then 'Weekday' //Monday
elseif(DATEPart('weekday',[Date])=3) then 'Weekday' //Tuesday
elseif(DATEPart('weekday',[Date])=4) then 'Weekday' //Wednesday
elseif(DATEPart('weekday',[Date])=5) then 'Weekday' //Thursday
elseif(DATEPart('weekday',[Date])=6) then 'Weekday' //Friday
elseif(DATEPart('weekday',[Date])=7) then 'Weekend' //Saturday
end

The Application

Video 1 shows how you can create this type of bucket.  Originally I created this post with information on why I needed this bucket.  I completed the article, published it, only to find out that WordPress somehow saved an earlier version, rather than the final post.  I’ll take that as a message to stop the post now. I’m not going to bore you with the details of why I needed this bucket, but suffice it to say that it is useful if you want to compare what happens during the week to what happens during the weekends.

6 thoughts on “Using #Tableau Buckets To Compare Weekday To Weekend Data

    • Hi Paul,

      Thanks for the comment, I appreciate it. I remember writing this post. I had written a masterpiece (at least in my mind) only to have it eradicated by the press of a button. The reason I wrote this was to compare my weekend vs weekday physical activity data using my fitbit database. After completing the calculated field, I realized it might also be a good thing to use in business to compare weekday vs weekend sales, for example. Thanks for reading, and I’m enjoying your blog, too!

      Ken

  1. Pingback: Using #Alteryx to Install #Tableau Buckets In Your Data Set | 3danim8's Blog

Leave a Reply

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