This week’s #workoutwednesday was about comparing last 2 periods sales for a sub-category using date functions with customize tooltips.

Requirements

  • Dashboard size should be 1000×600.
  • Sub-Category on the Rows Shelf, and Year of Order Date on the Columns Shelf
  • There are 3 measures, Sales, % of Total (in year) and % Difference
  • Only the Sales Measure has color (which colors you use don’t matter, just that Sales is the only measure colored).
  • Users can select a Year and a Measure and sort the table in Descending order by that measure in that year.

Dataset used was superstore dataset available with Tableau

Below is my attempt to meet the above requirements:

Thanks for reading 🙂

Do subscribe to blog for keep receiving updates

This week in #makeovermonday challenge was about UK’s Favorite Chocolate Bar as we are approaching Easter this week

Data was shared by CDA

Here is the original report and how it looks:

Data is share on makeovermonday.co.uk week 13.

In my attempt I tried to use the sigmoid function and tried to create Sankey chart.

Here is my attempt for #makeovermonday for UK’s Favorite Chocolate:

Thanks!!
Do subscribe to keep receiving regular updates

 

This week’s #workoutwednesday was about comparing last 2 periods sales for a sub-category using date functions with customize tooltips.

Requirements

  • Dashboard size should be 600×700.
  • The Change field should be displayed as a number, not a string.
  • Sub-Category should be sorted ascending by Change.
  • Tooltips should match exactly.
  • Prior Month and Most Recent Month should always be matching days, for example: If the max order date is 6/15/2017: the most recent month range should be orders between 6/1/2017-6/15/2017 and the prior month range should be 5/1/2017-5/15/2017.
  • Make sure your audience knows the dates in question by providing a note about the date ranges above the viz, and make sure that the date range displays match the colors of the dots in the viz..
  • Display the x-axis on top of the viz, and use the traditional x-axis space for a color legend.
  • Show the mark label on hover *for the most recent month only*. If the value for the most recent month is *lower* than the prior month, the mark label should be displayed to the left of the dot. If the value for the most recent month is *higher* than the prior month, the mark label should be displayed to the right of the dot.

Below is my attempt to meet the above requirements:

Thanks for reading 🙂

Do subscribe to blog for keep receiving updates

Today’s blog we will learn about running R codes with Tableau. R is the most used statistical tools by data scientests and researchers across the globe. Together, R & Tableau could be extremely useful in data science arena as it can help organisations to unravel end to end discovery needs.

Here in the blog we will go step by step process of integrating R & Tableau

Prerequisite: R studio & Tableau already installed on machine

Step 1

Install Rserve Package on your R software

install.packages("Rserve", repos="https://cran.rstudio.com/bin/windows/contrib/3.4/Rserve_1.7-3.zip")
## Error in install.packages : Updating loaded packages

Once the package is installed, we will run below command to load the package

library(Rserve)
Rserve()
## Starting Rserve...
##  "C:\Users\HP-LAP~1\DOCUME~1\R\WIN-LI~1\3.4\Rserve\libs\x64\Rserve.exe"

This will start the server in the background to enable Tableau to execute commands on R

Step 2

Now we will connect Tableau to R server using following

Help –> Setting and Performance –> Manage external Service connection

This will open the below shown window with auto populated values for Server as “Localhost” and port as “6311”.

Click on Test connection to check the connection, it will show successfully connected to Rserve in pop-up

click on ok
This will help Tableau to execute script commands like:
Script_BOOL
Script_INT
Script_STR
Script_REAL

Step 3

We will take below FMCG example as our data source and import into Tableau

Step 4

Now, we will create an calculated field “Outliers” using following code to find outliers in the FMCG data:

IF SCRIPT_REAL(“library(pracma); a <- rep(1, length(.arg1)); a[findpeaks(.arg1,threshold=quantile(.arg1,.99),sortstr=FALSE)[,2]]=0;a;”, SUM([Sales])) == 0
THEN “Outlier”
ELSE “OK”
END

One more calculated field “Cluster” with following code

SCRIPT_INT(
‘set.seed(42);result <- kmeans(data.frame(.arg1,.arg2,.arg3,.arg4), .arg5[1]);result$cluster;’,
max([Sales]), SUM([Profit]),min([Freight Expenses]),MIN([Discount offered]),3)

Step 5

Drag order date on column shelf and sales on row shelf then drag “Outliers” into color

As you can see all the outlier values are highlighted in orange while other values are in blue color. This way we can find outliers in our data very easily by using dream team of Tableau and R

Step 6

Lets go one step further and see if we can do clustering in Tableau with R.

Drag Sales into column shelf and profit into row shelf (unselect analysis –> aggregate measure) then drag calculated field “Cluster” to color in marks area and add trendline in the chart. We will see it creates 3 clusters as shown below:

Hope this blog helps to understand how to run Rserver in background and execute R scripts using Tableau.

you can download tableau file from here

Thanks for reading the blog

Do subscribe to my blog and keep receiving new posts 🙂