JCS Analytics
JCS Analytics
  • Home
  • About
  • Privacy

JCS Analytics - We are analysts. We Ask. We Automate. We Discover.

Details
By J. Smith
J. Smith
Articles
January 6,2024
Hits: 568
  • Tableau
  • DATETRUNC
  • Calculated Field

Creating a Calculated Field in Tableau to Get Get Data Aggregated by Month in the Correct Order

Creating a visualization for the most recent 12 months in Tableau can be a common requirement for time series analysis. To achieve this, you can use the `DATETRUNC` function to truncate your date data to the first day of each month, ensuring that your months will be in the correct order when aggregated. Here's how to use the `DATE(DATETRUNC('month',[Date]))` function effectively in Tableau for this purpose.

Understanding the DATETRUNC Function

The `DATETRUNC` function in Tableau truncates a given date to the specified date part, such as the year, quarter, or month. When you use `DATETRUNC('month', [Date])`, it will return the first day of the month for each date in your dataset. This is useful for creating consistent monthly data points for visualization purposes.

Steps

  1. Create a Calculated Field: In Tableau, create a new calculated field using the formula `DATE(DATETRUNC('month',[Date]))`. This will convert all dates in your dataset to the first of their respective months, without including the time along with the date. Only the date is necessary.
  2. Apply a Relative Date Filter: To focus on the most recent 12 months, apply a relative date filter to your worksheet. Add the date dimension to the filter and select 'relative date', then choose 'last twelve months'. This filter will automatically update as time progresses, ensuring that your visualization always represents the latest 12-month period.
  3. Use the Calculated Field in Your Visualization: Drag your new calculated field to the appropriate shelf (usually Columns) to use it as the axis for your visualization. This will ensure that your data is aggregated by the truncated month date, which will sort the months in chronological order.
  4. Adjust Aggregation as Needed: If you need to aggregate your data in a specific way (e.g., sum, average), make sure to adjust the aggregation settings for your measure values accordingly.
  5. Customize Your Visualization: You can now build your visualization as desired, whether it's a line chart, bar chart, or any other type that benefits from a monthly time series analysis.

Benefits of Using DATETRUNC

  • Consistency: By truncating dates to the first of the month, you ensure that each month is represented consistently, which is crucial for accurate comparisons and trend analysis.
  • Ordering: Truncated dates will naturally fall into chronological order, which is essential for time series visualizations.
  • Flexibility: You can easily adjust the level of date truncation (e.g., to quarters or years) if you need to analyze your data at a different granularity.

Using the `DATE(DATETRUNC('month',[Date]))` function in Tableau is a powerful way to prepare your data for visualizations that require monthly aggregation. It ensures that your months are in order and that your visualization reflects the most recent 12-month period. This approach is part of Tableau's robust time series analysis capabilities, which allow for insightful trend spotting and variance analysis over time.

Frequently Asked Questions

Can this method be applied to other time units (like weeks or days) and if so, how would the approach change? 
The DATETRUNC function can indeed be applied to other time units such as weeks or days. The approach remains similar, but the unit of truncation in the function needs to change (e.g., 'week' or 'day') to reflect the desired aggregation level.

How can you use the calculated field created with DATETRUNC in Tableau to compare year-over-year data? 
To compare year-over-year data using DATETRUNC, you can create separate calculated fields for the current and previous years by manipulating the date part of your DATETRUNC calculation. Then, use these fields in your visualization to compare performance across different years.

What are the best practices for ensuring that the date formatting in the calculated field matches the rest of the dashboard elements in Tableau?
Best practices for consistent date formatting include setting the default date format in the data source, using calculated fields to standardize date formats, and applying consistent formatting settings across dashboard elements directly within Tableau's format options.

 

Details
By J. Smith
J. Smith
Portfolio
December 9,2023
Hits: 664
  • Tableau
  • Data Analysis
  • Data Exploration
  • Data Visualization
  • Python

Utilizing CDC's COVID-19 Vaccination Data for Interactive Visualization

This project focuses on the utilization of a comprehensive dataset from the Centers for Disease Control and Prevention (CDC) to create interactive, color-coded visualizations that show the status of COVID-19 vaccinations across the United States. The dataset, although no longer updated, is a valuable resource for honing data cleaning skills in Python and developing interactive visualizations in Tableau.

The dataset, accessible to the public without restrictions, is a mix of aggregate, non-aggregate, and overlapping data. To ensure the accuracy and reliability of the analysis and visualization, a meticulous review and cleaning of the data are required.

Data Cleaning in Python

The data cleaning process in Python involves several steps:

  1. Removal of unnecessary columns. These are values that can be calculated in Tableau.
  2. Exclusion of rows containing aggregate or overlapping data.
  3. Exclusion of rows pertaining to US territories outside the 50 states.
  4. Creation of 'Gender' and 'Age Group' columns using values from 'Demographic_Category'.
  5. Removal of the 'Demographic_Category' column, which is now redundant.
  6. Renaming of three columns, including 'Location', which is renamed to 'State'. This allows Tableau to automatically recognize US state abbreviations as geographic data, facilitating map creation.
  7. Matching of state abbreviations to state names by merging the dataset with another dataset containing state names.
  8. Saving of the cleaned data for subsequent visualization in Tableau.

Link to Python code on Github

Visualization in Tableau

The cleaned data is used to create two interactive visualizations in Tableau:

  1. 1. An interactive map displaying the percentage of the population up to date with COVID-19 vaccinations by state. Users can select any combination of age group, gender, and date to observe changes in values.
  2. An interactive bar chart showing the percentage of the population up to date with COVID-19 vaccinations by age group. Like the map, users can select any combination of age group, gender, and date to see how the values change.
  3. Notes about the data.

Link to visualization on Tableau Public

Data Source

Centers for Disease Control and Prevention (CDC) Public Data
COVID-19 Vaccines Up to Date Status
https://data.cdc.gov/Vaccinations/COVID-19-Vaccines-Up-to-Date-Status/9b5z-wnve/data

Published by: Centers for Disease Control and Prevention (CDC)
Public Access Level: Data asset is publicly available to all without restrictions (public)
License: Public Domain U.S. Government

Details
By J. Smith
J. Smith
Portfolio
November 5,2023
Hits: 772

Bank Customer Churn Analysis: A Comprehensive Overview

The analysis of customer churn is a critical task that can significantly impact a bank's profitability and long-term success. Churn, the rate at which customers leave a bank, can be influenced by factors such as  customer service quality, product offerings, and competitive dynamics within the industry.

The dataset includes a range of variables such as customer demographics, account details, and transaction history, which are necessary for understanding the patterns of customer churn.

The project involved a multi-stage process, beginning with data exploration and cleaning using Python. Python is a powerful tool for data manipulation, allowing for efficient identification and resolution of data quality issues. This step is crucial before any further analysis to ensure the integrity of the dataset.

Once the data was prepared, I did a basic statistical analysis to look for anything interesting or unusual. Generating a correlation heatmap led to an important discovery: a perfect correlation (correlation of 1) between customers who complained and those who exited the bank, a finding that suggests customer complaints are a strong predictor of churn. Addressing customer grievances could be a key strategy in reducing churn rates.

Further exploration and visualization were carried out in Tableau to complement the analysis in Python. Tableau is a powerful visualization tool that can help in presenting data in an intuitive and impactful manner. The insights gained from the Python analysis, particularly the strong correlation between complaints and churn guided the creation of visualizations with Tableau.

The combination of Python for data preparation and statistical analysis, followed by Tableau for visualization, is a robust approach to understanding and addressing customer churn in banking. By utilizing these tools, banks can gain a deeper understanding of what causes customer churn and develop strategies to improve customer retention.

This bank churn analysis project underscores the importance of a thorough and methodical approach to data analysis in any project. Utilizing the strengths of both Python and Tableau provided actionable insights to reduce customer churn and improve the bank's competitive edge.

Bank Churn Analysis from https://www.kaggle.com/datasets/mathchi/churn-for-bank-customers (License - CC0: Public Domain)

Link to project files on GitHub

Link to visualizations on Tableau Public

Correlation heatmap from the data analysis in Python that revealed the strong relationship between customers who complained and those who exited the bank (variables 'Exited' and 'Complain'):

 

 

 

 

 

Details
By J. Smith
J. Smith
Tableau
October 18,2023
Hits: 785
  • Tableau
  • 5K@EASD
  • Data Visualization

Exploring the 2023 5K@EASD Virtual Run: A Tableau Analysis

Delve into the fascinating statistics from the 2023 5K@EASD virtual run. This analysis serves as a testament to the power of Tableau, a tool that allows us to visualize and understand data in a matter of minutes.

You can explore the full analysis in our 5K@EASD Story Points on Tableau Public.

Story Points Breakdown

  1. Welcome: An introduction to the analysis.
  2. Participants by Country: A vibrant, color-coded map that displays the number of participants from each country.
  3. Countries with 100 or More Participants: Interactive bar charts that show the number of participants by country and gender. You can select any combination of country and gender to see how the counts change.
  4. My Bib and Results: A personal touch to the analysis.

We hope this analysis provides you with a clear understanding of the 2023 5K@EASD virtual run's reach and impact. We also hope it demonstrates the potential of Tableau as a powerful tool for data visualization and analysis.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

Page 8 of 9

Articles

  • Articles

News

  • Novo Nordisk and Valo Health Expand AI-Powered Partnership to Address Cardiometabolic Diseases
  • Denmark’s Gefion AI Supercomputer Powers Innovation and Global Challenges

Portfolio

  • Working with CGM Data: Python, SQLite, and Tableau in a 4-Part Series
  • Visualizing the 5K@ADA Race Results
  • Complex Web Scraping with Python
  • Adapting the 5K@ADA Race Results Project for 2025

Contact Me

Search

End Diabetes Stigma

5K@ADA

5K@EASD

World Diabetes Day

Rochen Web Hosting

Bluesky Social

  • You are here:  
  • Home
 
Copyright © 2025 JCS Analytics. All Rights Reserved.
Joomla! is Free Software released under the GNU General Public License.