Tableau Tips : Comparing Sales with previous Business Day

In today’s tableau tip we are going to see how do we compare the sales of a custom selected date with the previous business day sales and calculate the percentage change in the sales. For example if the user selects a particular date which is Friday then the sales of Friday must be compared with Thursday sales . However if the user selects a date that is Monday then we should compare the sales with Friday and not Sunday.In by any chance the user selects any date that is either Saturday or Sunday , no sales value must be displayed. Hope I am clear with the context that we are looking into.
To achieve this we will use our sample superstore data that can be found here : Sample – Superstore
The first step is to create a parameter that allows the user to select the custom date he wants. This is quite simple and here the way to do it:
The second step would be to create a calculated field that evaluates if the selected date is a weekend ( Saturday/Sunday ) or a working day. This is done as under :

Here we have taken the value of weekday as 1 and 7 for weekends as Tableau defines 1 as Sunday and 7 as Saturday until and unless specified by the user.
Once we have identified our selected day as a working day/ weekend our next job is to get the sales value for the selected day. If the date is a working day then we will return the value of sales else the value of sales would be null. This is done as under:
Next we will create a calculated field to identify the sales on the Selected business day as under :
Most of our job is done now , the only thing left is calculate the day before the selected date and the sales value for the previous day. The following two calculated filed help us to achieve it :


We are done now and the only thing left is to place the fields in their respective places.
Drag Business day to Columns and measure names to the filters area. Select the measures Sales on Selected Business Day and Sales on a day before business day.
Drag measure names to the rows and place the measure values on the text mark. Click on the date parameter and select show parameter control.
Change the date from the parameter and you can see the sales of previous day. If the selected date is a weekend no sales will be displayed and in case of Monday we will get the sales of Friday.
Here is the workbook that displays the same .

I have left the calculation for the percent change to you guys. Give it a try and see if you can get it . Ping me back in case if you are not able to get it or have any doubts regarding the same.


Please follow and like us: