<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Antonio Pacheco on Medium]]></title>
        <description><![CDATA[Stories by Antonio Pacheco on Medium]]></description>
        <link>https://medium.com/@antoniocnpacheco?source=rss-4d911a835965------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g1L5h66WLQ59jifY8WM4Mw.jpeg</url>
            <title>Stories by Antonio Pacheco on Medium</title>
            <link>https://medium.com/@antoniocnpacheco?source=rss-4d911a835965------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:13:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@antoniocnpacheco/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SQL and Tableau: Data cleaning and vizualization]]></title>
            <link>https://medium.com/@antoniocnpacheco/sql-and-tableau-data-cleaning-and-vizualization-4b6eef867041?source=rss-4d911a835965------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b6eef867041</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[tableau]]></category>
            <dc:creator><![CDATA[Antonio Pacheco]]></dc:creator>
            <pubDate>Tue, 15 Aug 2023 08:32:51 GMT</pubDate>
            <atom:updated>2025-05-12T21:08:09.838Z</atom:updated>
            <content:encoded><![CDATA[<p>A two articles series about data cleaning, visualization and exploratory data analysis</p><p>After bringing an overview about basic data visualization with SQL and Tableau in my <a href="https://medium.com/@antoniocnpacheco/sql-and-tableau-data-visualization-a5e96888a402"><strong>previous article</strong></a>, I’m exploring in this article data that would demand a visualization in Tableau but not only that.</p><blockquote>In the nexts articles, I will also show how I went throught the data available minding business questions and applied a correlation analysis and a machine learning model for forecasting purposes</blockquote><p>Using a dataset available on Kaggle, I describe below the following steps to select the relevant data using SQL Server to build a sales report on Tableau:</p><ol><li><strong>Data input</strong></li><li><strong>Data cleaning</strong></li><li><strong>Dashboard construction</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*EJ7zZcRhPDFpTSlJhKR00A.gif" /></figure><p>Access the <a href="https://github.com/anpac20/sales_dataviz"><strong>Github repo</strong></a><strong> </strong>and the<strong> </strong><a href="https://public.tableau.com/app/profile/ant.nio.pacheco/viz/SalesReport_16868672658560/Report"><strong>Tableau viz</strong></a>.</p><h4>1. Data input</h4><p>The data used here consists in historical grocery sales. The dataset describes the daily sales (in unities) by product during 4 years, in 50 stores. The whole data set had a total of 120 milion rows and I input the data into SQL Server using a BULK INSERT statement.</p><p>The full project can be found on this <a href="https://github.com/anpac20/sales_dataviz"><strong>Github repo</strong></a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d945fd680719874bf501f832fc268665/href">https://medium.com/media/d945fd680719874bf501f832fc268665/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*ScUrbM-48K9R0Bm1bSUfYw.png" /><figcaption>From the first queries, it is possible to notice a huge amount of rows (more than 12 million) and the columns available in the original dataset</figcaption></figure><h4>2. Data cleaning</h4><p>Since the original dataset had a massive amount of rows, my first goal was to filter the data in order to enable an overview for just some of the stores during the last year reported.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6a79ef0f006ba2b71928a306894f3ac/href">https://medium.com/media/d6a79ef0f006ba2b71928a306894f3ac/href</a></iframe><p>After cutting the dataset, I joined three tables (sales, stores and items) to present cities and categories (refered as “families” in this dataset) information. For this, the JOIN statement can be used twice in a same query, as you can see below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70186c0be478534dba0e5e7bbefe80e2/href">https://medium.com/media/70186c0be478534dba0e5e7bbefe80e2/href</a></iframe><p>Because I don’t need a high level of detail, the third step was to group sold units by categories and cities. I also chose only columns that would be relevant to the visualization I want to build.</p><blockquote><strong>REMINDER</strong>: in a real world environment, we should be aware that those units might not be equivalent (e.g. kilograms and units), which would require other labels to perform a summarization</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77385641cb008901bc9fab9c4afd0a68/href">https://medium.com/media/77385641cb008901bc9fab9c4afd0a68/href</a></iframe><p>With information filtered and grouped, the output table presents 40 thousands and so rows, which ilustrates the importance of cleaning and summarizing the data before creating any charts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*NShfoH5zcFgul94JEuNuxw.png" /></figure><h4>3. Dashboard construction</h4><p>In order to use such a high number of rows as in input for my Tableau vizualiztion, I exported the table as a .txt file (one of the fastest/easiest ways to do it in the free version of the software).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*-TR5aSZe9BtB1EXb.png" /><figcaption>Tableau initial screen shows available ways to connect your project to a source file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqKGgXQw2o7NUYxbPcX04w.png" /><figcaption>After choosing the appropriate file type, you must find a scheme for each of the tables uploaded</figcaption></figure><p>Having the data available on Tableau, the views created were meant to be a simple and quick way to present the distribuition of sales among cities and families.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Nrw3661wejua4hKOoKkfLQ.gif" /><figcaption>To create a view, you must drag your coordinates — latitude and longitude in the case of a map — and them set properties such as format, color and size for each measure presented</figcaption></figure><p>After creating all my views, I presented them in a panel, which would be my dashboard. A more detailed description on how to create views and panels can be checked on my <a href="https://medium.com/@antoniocnpacheco/sql-and-tableau-data-visualization-a5e96888a402"><strong>first article</strong></a>.</p><p>All in all, I hope this ilustrates the stage of basic vizualization on data analysis. Analyses that would require more data, such as the correlation of sales and other variables should be approched on the <a href="https://anpac20.github.io/sales_descriptive_analaysis/"><strong>next article</strong></a><strong>.</strong></p><p>Feel free to connect to me on <a href="https://www.linkedin.com/in/pacheco-antonio/"><strong>LinkedIn</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b6eef867041" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL and Tableau: Data visualization]]></title>
            <link>https://medium.com/@antoniocnpacheco/sql-and-tableau-data-visualization-a5e96888a402?source=rss-4d911a835965------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5e96888a402</guid>
            <category><![CDATA[data-analytics-tools]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[tableau]]></category>
            <dc:creator><![CDATA[Antonio Pacheco]]></dc:creator>
            <pubDate>Sun, 27 Mar 2022 22:25:46 GMT</pubDate>
            <atom:updated>2024-06-20T15:06:49.654Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>An end-to-end tutorial for beginners about how to prepare raw data for a visual analysis</strong></h4><p>When I decided I was going to live in Ireland, coming from Brazil, I knew I’d have some issues getting used to the weather so in order to get an overview about climate conditions in the country, I decided to create this project to help people seeking help during their first steps in analytics. Here therefore you can see how I prepared a <a href="https://public.tableau.com/app/profile/ant.nio.pacheco/viz/IrishWeatherData/Dashboard">visualization of Irish weather data</a> using SQL Server and Tableau.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/0*giBpEQNO3G8Zp7UZ.gif" /></figure><p>To make it easier to follow, the process is organized in five sections covering the main steps to manipulate and visualize raw data:</p><ol><li><strong>Data source</strong></li><li><strong>Set up</strong></li><li><strong>Raw data and prototypes</strong></li><li><strong>Dataset handling</strong></li><li><strong>Dashboard construction</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D6naBey1EDc8aVBwohIDVw.gif" /><figcaption>SQL Server is used here to prepare the data once it is suitable to both simple and complex tasks envolving large datasets. The final result was built using Tableau Public, an eficient tool for building effective and shareble visualizations</figcaption></figure><h4>1. Data source</h4><p>Before we start, I would like to introduce you (in case you don’t know it yet) to <a href="https://www.kaggle.com/"><strong>Kaggle</strong></a>, a platform destinated to the data analysis community, where you can find this dataset and a lot of other interesting data.</p><p>When it comes to the weather data used on this project, you can find it available on Kaggle or download your own set in the The Irish Meteorological Service <a href="https://www.met.ie/climate/available-data/historical-data"><strong>website</strong></a>.</p><h4><strong>2. Set up</strong></h4><p>First of all, once the .csv file is downloaded, you can see below how to open it using SQL Management Studio and create a new table with its information. At the end of the importing process, it will be possible to visualize and work with the raw data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xCfoEL6GVWLR42m-U4-NKg.png" /><figcaption>You can upload a file creating a new table in a database through the option “Import Flat File”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lm0oxJ3jVwFNNlad94Xl0A.png" /><figcaption>A new window with an assistant will show the steps to upload the file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8bpsxjp0y9iRkX-0JuWtDw.png" /><figcaption>Once the table is available, it’s possible to use queries to view or edit it</figcaption></figure><h4>3. Raw data and prototypes</h4><p>It’s always good to remember that a good way to start working with any data is knowing what are the main goals. Although you might change ideas while working on it, deeply knowing your original dataset and the needed columns for visualization is the best first step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*YWCJ5qWZIubwcjjlXC6Xvg.png" /></figure><p>That said, I also highly recommend the construction of a dashboard mockup, that helps us to determine which information is useful and also which operations have to be done in order to bring the right metrics to the visualization tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*CVEIiAsayVDByNPCIff7BQ.png" /><figcaption>The sketching is quick, risk-free and helps to think about our main goals</figcaption></figure><h4>4. <strong>Dataset handling</strong></h4><p>To perform the analysis itself, my main interests were temperature, wind and rain, so the first queries were dedicated to bring those columns and filter the information related to 2019 in order to reduce the amount of data I’d deal with.</p><p>Also, location indicators like “county”, “station”, “latitude” and “longitude” were kept and time markers like “date” and “time” were created in the “hrly_data_2019” table.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37f186cb1e8e561fce91bc24ff21dee6/href">https://medium.com/media/37f186cb1e8e561fce91bc24ff21dee6/href</a></iframe><p>Besides the actual weahter information, I also created a table with counties and respective geolocation considering the mean of latitude and longitude of stations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6f951bb79d45dbb4ec8efb6ca33c7d6/href">https://medium.com/media/b6f951bb79d45dbb4ec8efb6ca33c7d6/href</a></iframe><p>Now, it’s time to organize the weather data, so I first aggregated rain, temperature and wind speed by county, calculating the average for these metrics in cases with more than one station per county.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2be1b40a288d2ca5afc4858a6e8fddd/href">https://medium.com/media/f2be1b40a288d2ca5afc4858a6e8fddd/href</a></iframe><p>After this, I aggregated the data again, sinthetinzing the hourly data into daily information because I don’t need so much detail for the overview. For this, each metric is calculated in a different way, once for rain, you must sum up the total precipitation amount but for wind speed, for example, I am getting the highest value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/076023e0d89f718592bdda5575a0619c/href">https://medium.com/media/076023e0d89f718592bdda5575a0619c/href</a></iframe><p>Last but not least, in order to shape the data according to my visualization purposes, the last query was built to join the data information to the counties geolocation using a JOIN statement.</p><p>In addition, the CASE WHEN statement was used here to created classification columns considering existing columns values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12e6f4f1d4ae9f9cf85cdf146e510cc2/href">https://medium.com/media/12e6f4f1d4ae9f9cf85cdf146e510cc2/href</a></iframe><h4>5. Dashboard construction</h4><p>Last but not least this project’s final step consists on the creation of the dashboard using <a href="https://public.tableau.com/app/profile/ant.nio.pacheco"><strong>Tableau Public</strong></a>, a powerful tool when it comes to building insights and sharing them.</p><p>For this tutorial, I exported the data and imported it mannually into Tableau but if you have enough budget for a licence, you should be able to connect the tools as it’s shown <a href="https://help.tableau.com/current/pro/desktop/en-us/examples_sqlserver.htm"><strong>here</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jmk23UZJRA2djVuCp78sFg.png" /><figcaption>To read the data on Tableau, you first must export the dataset from SQL Server as a compatible to be used as a data source.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nM3i8P2Ir8uxoau_S_iSnw.png" /><figcaption>To import the file to Tableau, you must then select the correspondent type to set it as a new connection</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6N9Kw_6woZdTkF9hNwqS9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uCsWW2mrTz3MWhiJV4J6ng.png" /><figcaption>Once the new data source is connect, you must be able to drag the tables you want to use in the views</figcaption></figure><p>With tables available, you can then build visualizations through Tableau tools, organized by the following parts:</p><ul><li>Side bar: contains a data pane with metrics (divided between dimensions and measures)</li><li>Sheets: used to create views using the metrics from the data source</li><li>Dashboards: used to gather and organize views from multiple sheets</li></ul><p>The views can be created by clicking and draging metrics, which can be used by Tableau to suggest the best type of chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kDpoP-Tm70TLVxFj8cJEw.gif" /><figcaption>Any views can be created dragging metrics to the worksheet and selecting which information is going to be shown in the labels, for example</figcaption></figure><p>Once all the visualizations are created, dashboards are useful tools to organize them and build sets of views to communicate ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q7QXQ2nYX2RvzYxNh0CUYw.gif" /><figcaption>The dashboards can be created using the existing views dragging them and adjusting the layout to organize the information</figcaption></figure><p>All done, the work can be save to Tableau Public, where other people can check out, download and contribute to your discoveries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LvWSUN7A-fcP6LAAbM_t7Q.gif" /></figure><p>That’s all folks! As I said, my intentions here are to cover the basics and show the main steps to make the process of visualization tangible for beginners. However, feel free to reach out in case of any questions about the projects or the tools. I’ll be happy to help!</p><p>Also, if you want to connect, this is my <a href="https://br.linkedin.com/in/pacheco-antonio"><strong>LinkedIn profile</strong></a>. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5e96888a402" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>