From Messy Data to Dashboard
Clean sales data in Excel, query it in PostgreSQL, and publish a Tableau dashboard.
Introduction
30 Second Summary
Every business generates mountains of sales data. The challenge is turning that messy, inconsistent information into something a manager can actually read and act on.
In this project, you will take a messy e-commerce sales dataset and transform it into a polished, interactive dashboard. You will clean the data in Excel, query it with PostgreSQL, and visualize it in Tableau.
What You'll Build
You will build an end-to-end data analysis pipeline that takes a raw, messy CSV file through cleaning, SQL querying, and visualization to produce a published interactive dashboard.
By the end of this project, you'll have:
- A cleaned CSV file exported from Excel with standardized dates, no duplicates, and no missing values.
- A PostgreSQL database with imported sales data and analytical SQL queries that extract business insights.
- A published Tableau Public dashboard with charts showing revenue trends, top products, and regional performance.
- Secret Mission: Add interactive filters and calculated fields to make your dashboard drill-down capable.
Are there any prerequisites?
None. This guide includes full setup instructions for all required tools. You just need a Windows PC with Microsoft Excel already installed.
Before We Start
This project uses three tools to build a complete data analysis pipeline. You will clean data in Excel, query it in PostgreSQL, and visualize results in Tableau.
In this step, you will install PostgreSQL and Tableau Desktop Public Edition on your Windows PC, then download the messy sales dataset you will work with throughout the project.
In this step, get ready to:
- Install PostgreSQL 18 with pgAdmin.
- Install Tableau Desktop Public Edition.
- Download the messy sales dataset and open it in Excel.
Download and install PostgreSQL 18
PostgreSQL is the database where you will store and query your cleaned sales data. The EDB Interactive Installer bundles everything you need: the PostgreSQL server, pgAdmin (a graphical management tool), and StackBuilder.
- Check if PostgreSQL is already on your machine by opening Command Prompt and running this command:
psql --version
Look at what appears in your terminal, then select the matching tab below.
✔️ I see version 18 or higher
Your output looks something like:
psql (PostgreSQL) 18.4
PostgreSQL 18 is already installed. Skip ahead to the next substep where you verify pgAdmin.
ⓧ I see an older version
Your output shows a version number below 18 (for example psql (PostgreSQL) 16.4). You need to upgrade to version 18.
- Open Add or remove programs from the Windows Start Menu.
- Find PostgreSQL in the list and click Uninstall.
- Follow the uninstaller prompts to remove the old version.
- Once uninstalled, follow the full install instructions in the next tab to install PostgreSQL 18.
ⓧ Command not found
You see a message saying the command is not recognized. This means PostgreSQL is not installed yet. Follow the steps below to install it.
- Open your browser and go to the EDB downloads page:
- https://www.enterprisedb.com/downloads/postgres-postgresql-downloads.
- Find the row for PostgreSQL version 18 and click the Windows x86-64 download link.
- Run the downloaded installer file.
- On the Select Components screen, make sure PostgreSQL Server, pgAdmin 4, and Command Line Tools are all checked.
- On the Password screen, set a password for the postgres superuser. Write this password down somewhere safe. You will need it later.
- On the Port screen, keep the default value of 5432.
- Click Next through the remaining prompts, then click Finish when the installation completes.
- If StackBuilder launches after the install, close it. You do not need it for this project.
What did the installer just set up?
The EDB installer created a PostgreSQL server running as a Windows service on port 5432. It also installed pgAdmin (your graphical database tool) and added the PostgreSQL bin folder to your system PATH so you can run psql commands from the terminal.
- Verify pgAdmin works by pressing the Windows key to open your search bar.
- Type pgAdmin and press Enter to open it.
- When pgAdmin opens in your browser, it may ask you to set a master password. Choose any password you will remember (this is separate from your postgres database password).
- In the left sidebar, expand Servers. You should see PostgreSQL 18 listed. Click it to connect. If prompted, enter the postgres password you set during installation.
You should see the server show a green checkmark or connection indicator in the sidebar.
pgAdmin won't connect to the server?
Make sure the PostgreSQL service is running. Press the Windows key, type services.msc, and press Enter. Look for a service named postgresql-x64-18 and confirm its status shows Running. If it is stopped, right-click it and select Start.
If you forgot your password, you will need to uninstall and reinstall PostgreSQL to reset it.
Still stuck? Help me connect pgAdmin to my local PostgreSQL 18 server on Windows.
Download and install Tableau Desktop Public Edition
Tableau Desktop Public Edition is a free data visualization tool. You will use it to build an interactive dashboard from your query results.
- Open your browser and go to https://public.tableau.com.
- Click Download the App.
- Fill out the registration form with your email and details.
- Click Download the App again on the form to start the download.
- Run the downloaded installer and follow the prompts to complete the installation.
Do I need a license?
Tableau Desktop Public Edition is completely free and does not require activation or a product key. You only need a Tableau Public account (which you create during registration) to publish your dashboards later.
- After installation, press the Windows key to open your search bar.
- Type Tableau Public and press Enter to open it.
- Confirm that Tableau Desktop Public Edition opens to its Start page, which shows connection options on the left and recent files on the right.
Create your Tableau Public profile now
If you do not already have a Tableau Public profile, visit https://public.tableau.com and sign up. You will need this profile in Step 5 when you publish your dashboard.
Tableau won't open?
Make sure the installer finished completely. Try restarting your computer and opening Tableau again from the Start Menu.
Still stuck? Help me troubleshoot Tableau Desktop Public Edition not opening on Windows.
Download the messy sales dataset
The dataset for this project is a CSV file with approximately 500 rows of e-commerce order data. It contains intentional quality issues that you will fix in the next step.
- Create a project folder to keep your files organized. Open File Explorer and navigate to your Documents folder.
- Right-click in the empty space, select New, then Folder. Name it sales_project.
- Download the messy sales dataset file from the project resources link on this page.
- Save the downloaded CSV file into your sales_project folder.
What is in this dataset?
The CSV contains e-commerce order data with columns for order ID, date, product name, category, quantity, unit price, and region. It has intentional problems: inconsistent date formats, duplicate rows, missing values in quantity and price columns, extra spaces in product names, and inconsistent capitalization in category names.
These are the exact kinds of data quality issues you will encounter in real analyst work.
- Open the CSV file in Microsoft Excel by double-clicking it in your sales_project folder.
- Confirm that you can see data in the spreadsheet. You should see approximately 500 rows with columns like order_id, order_date, product_name, category, quantity, unit_price, and region.
Scroll through a few rows. Notice the messy dates (some show MM/DD/YYYY, others show DD-Mon-YYYY), blank cells, and inconsistent capitalization. You will fix all of this in the next step.
Excel shows everything in one column?
If all the data appears crammed into column A, Excel did not parse the CSV correctly. Close the file, then reopen it using File then Open. Select the file and make sure Delimited is selected in the Text Import Wizard with Comma checked as the delimiter.
Need help? Help me open a CSV file in Excel so each value appears in its own column.
Your environment is ready. Next up, you will clean this messy dataset in Excel and transform it into analysis-ready data.
Install PostgreSQL and Tableau
Before you can clean data, run queries, or build dashboards, you need the three tools that make up a data analyst's daily workflow.
In this step, you will install PostgreSQL (a database for storing and querying data), Tableau Desktop Public Edition (a visualization tool for building dashboards), and download the messy dataset you will transform throughout this project.
In this step, get ready to:
- Install PostgreSQL 18 with pgAdmin on your Windows PC.
- Install Tableau Desktop Public Edition and create a Tableau Public account.
- Download the messy sales dataset and confirm it opens in Excel.
Download and install PostgreSQL 18
PostgreSQL is the database engine where you will store your cleaned sales data and run analytical queries. The EDB Interactive Installer bundles PostgreSQL with pgAdmin, a graphical tool for managing your database without memorizing terminal commands.
- Press the Windows key to open your search bar.
- Type Command Prompt and press Enter to open it.
- Check if PostgreSQL is already installed by running this command:
psql --version
What does this command do?
This asks your system to report which version of the PostgreSQL command-line client is installed. If PostgreSQL is present and added to your PATH, you will see output like psql (PostgreSQL) 18.4.
✔️ I see version 18 or higher
PostgreSQL 18 is already installed on your machine. Skip ahead to verifying pgAdmin below.
ⓧ I see an older version
You have an older PostgreSQL installation. You can install version 18 alongside it using the EDB installer. The installer will use a separate directory and port if it detects an existing installation.
- Open your browser and go to the PostgreSQL Windows download page:
- https://www.postgresql.org/download/windows/
- Click the link to Download the installer certified by EDB.
- Select the latest PostgreSQL 18 installer for Windows x86-64.
- Double-click the downloaded installer file. If Windows asks for administrator permission, click Yes.
What will the installer ask you?
The installer walks you through several screens. Here is what to do at each one:
- Installation Directory: accept the default path.
- Select Components: ensure PostgreSQL Server, pgAdmin 4, and Command Line Tools are all checked.
- Password: enter a password for the postgres user. Write this password down somewhere safe.
- Port: keep the default 5432. If that port is already in use by your older install, the installer will suggest 5433. Accept the suggested port.
- Locale: accept the default locale.
- Stack Builder: uncheck Launch Stack Builder at exit and click Finish.
After installation, you need to add the new PostgreSQL 18 to your system PATH so the psql command finds the correct version.
- Open System Properties by pressing the Windows key, typing Environment Variables, and selecting Edit the system environment variables.
- Click Environment Variables.
- Under System variables, find and select Path, then click Edit.
- Click New and add: C:\Program Files\PostgreSQL\18\bin.
- Move this entry above any older PostgreSQL bin paths using the Move Up button.
- Click OK on all open dialogs to save.
- Close your Command Prompt window and open a new one, then re-run psql --version to confirm it now shows version 18.
ⓧ 'psql' is not recognized
PostgreSQL is not installed yet. Follow these steps to install it from scratch.
- Open your browser and go to the PostgreSQL Windows download page:
- https://www.postgresql.org/download/windows/
- Click the link to Download the installer certified by EDB.
- Select the latest PostgreSQL 18 installer for Windows x86-64.
- Double-click the downloaded installer file. If Windows asks for administrator permission, click Yes.
What will the installer ask you?
The installer walks you through several screens. Here is what to do at each one:
- Installation Directory: accept the default path.
- Select Components: ensure PostgreSQL Server, pgAdmin 4, and Command Line Tools are all checked.
- Password: enter a password for the postgres user. Write this password down somewhere safe. You will need it later when connecting to your database.
- Port: keep the default 5432.
- Locale: accept the default locale.
- Stack Builder: uncheck Launch Stack Builder at exit and click Finish.
After installation, add PostgreSQL to your system PATH so you can use psql from any Command Prompt window.
- Press the Windows key, type Environment Variables, and select Edit the system environment variables.
- Click Environment Variables.
- Under System variables, find and select Path, then click Edit.
- Click New and add: C:\Program Files\PostgreSQL\18\bin.
- Click OK on all open dialogs to save.
- Close your Command Prompt window and open a new one.
- Run psql --version again to confirm you see psql (PostgreSQL) 18.4 or similar.
Now verify that pgAdmin is working.
- Press the Windows key and type pgAdmin.
- Click pgAdmin 4 to open it.
- When pgAdmin opens, it may ask you to set a master password for the application. Enter any password you will remember and click OK.
- In the left sidebar, expand Servers. You should see your local PostgreSQL server listed.
- Click the server name. If prompted for the postgres user password, enter the password you set during installation.
You should see the server status turn green, confirming pgAdmin is connected to your local PostgreSQL instance.
pgAdmin won't connect to your server?
- Make sure the PostgreSQL service is running. Press the Windows key, type Services, open the Services app, and look for a service named postgresql-x64-18. If it says Stopped, right-click it and select Start.
- Double-check that you are entering the correct password for the postgres user (the one you set during installation, not the pgAdmin master password).
Still stuck? Help me troubleshoot my pgAdmin connection to PostgreSQL.
Download and install Tableau Desktop Public Edition
Tableau Desktop Public Edition is a free data visualization tool that lets you build interactive dashboards and publish them to the web. You will use it to turn your SQL query results into charts.
- Open your browser and go to:
- https://public.tableau.com
- Click Download the App.
- Fill out the registration form with your email and details.
- Click Download the App again on the form to start the download.
- Once the download finishes, double-click the installer file to begin installation.
- Follow the installer prompts, accepting the default settings.
Do I need a license or product key?
Tableau Desktop Public Edition is completely free and does not require activation or a product key. You only need a Tableau.com account to publish your dashboards later.
- After installation completes, press the Windows key and type Tableau.
- Click Tableau Desktop Public Edition to open it.
✔️ I see the Tableau Start page
Tableau is ready. You should see the Start page with a Connect pane on the left listing data source options like Text File and Microsoft Excel.
ⓧ Tableau won't open or shows an error
- Try restarting your computer and opening Tableau again. Some Windows installations require a restart after new software is added.
- Make sure you downloaded Tableau Desktop Public Edition (the free version), not a trial of Tableau Desktop (the paid version).
- If you see a sign-in prompt, create a free Tableau Public account at https://public.tableau.com and sign in.
Still stuck? Help me troubleshoot Tableau Desktop Public Edition not opening on Windows.
If you do not already have a Tableau Public profile, create one now.
- Go to https://public.tableau.com in your browser.
- Click Sign Up and complete the registration with your name, email, and a password.
- Confirm your email if prompted.
Why do I need a Tableau Public account?
At the end of this project, you will publish your finished dashboard to Tableau Public. This gives you a shareable URL you can add to your resume or portfolio. The account is free and stores up to 10GB of visualizations.
Download the messy sales dataset
The dataset you will work with is a CSV file containing approximately 500 rows of e-commerce order data. It has intentional quality problems that you will fix in the next step.
- Download the sales_raw.csv file from the project resources at the top of this page.
- Create a new folder to keep your project files organized. Open File Explorer and navigate to your Documents folder.
- Right-click inside the Documents folder, select New, then Folder.
- Name the folder sales_project.
- Move the downloaded sales_raw.csv file into your new sales_project folder.
Now open the file in Excel to confirm you can see the data.
- Double-click sales_raw.csv inside your sales_project folder. It should open in Microsoft Excel.
- Scroll through the data. You should see columns like order ID, date, product name, category, quantity, price, and region.
What problems will you spot in this data?
Take a quick look and you will notice several issues. Dates appear in different formats (some as MM/DD/YYYY, others as DD-Mon-YYYY). Some product names have extra spaces. Category names mix uppercase and lowercase. Some rows are missing values for quantity or price.
These are all realistic problems that data analysts encounter every day. You will fix them systematically in the next step.
CSV file opens as a jumbled mess?
- If all the data appears in a single column, Excel may not have detected the comma delimiter. Close the file, then open Excel first, go to File then Open, select the CSV, and choose Delimited with Comma as the separator in the Text Import Wizard.
- If you see garbled characters, make sure you downloaded the file completely and it was saved as a .csv file (not .html or .txt).
Still stuck? Help me open my CSV file properly in Excel on Windows.
Your tools are installed and your data is ready. Next up, you will open that messy CSV in Excel and systematically clean it into analysis-ready shape.
Clean the Messy Data in Excel
Your tools are installed and your messy dataset is open in Excel. Now it is time to tackle the real challenge: transforming unreliable raw data into something you can actually analyze.
Real-world data is almost never clean. In this step, you will fix the five most common data quality problems that analysts encounter every day: inconsistent date formats, duplicate rows, missing values, extra whitespace, and inconsistent capitalization.
In this step, get ready to:
- Identify and fix data quality issues using TRIM(), DATEVALUE(), TEXT(), and Find & Replace.
- Remove duplicate rows and delete rows with missing values.
- Save the cleaned dataset as a new UTF-8 CSV file.
Identify and fix data quality issues
Before fixing anything, you need to understand what is wrong with the data. Your messy CSV has five problems that would produce incorrect analysis results if left unfixed.
- Scroll through the data in Excel and look for these issues:
- Inconsistent date formats in the order_date column (some show MM/DD/YYYY, others show DD-Mon-YYYY).
- Duplicate rows (exact copies of the same order).
- Missing values in the quantity and unit_price columns.
- Leading or trailing spaces in product_name (e.g., " Wireless Mouse " instead of "Wireless Mouse").
- Inconsistent capitalization in the category column ("electronics", "Electronics", "ELECTRONICS").
Why does this matter?
If you loaded this data into a database without cleaning it, "electronics" and "Electronics" would count as two separate categories. Your analysis would split the same group into multiple buckets, giving you wrong totals.
Now you will fix the product name spacing issue first. The TRIM() function removes leading and trailing spaces from text.
- Click on an empty cell in the first available column to the right of your data, in row 2 (the first data row after headers).
- Type the following formula, replacing C2 with the cell reference for the first product_name value in your spreadsheet:
=TRIM(C2)
- Press Enter to confirm the formula.
- Copy this cell down to all rows by selecting it, then dragging the small square in the bottom-right corner of the cell down to the last row of data.
What does TRIM() do?
TRIM() removes all leading spaces, trailing spaces, and extra spaces between words. It leaves single spaces between words intact. This ensures that " Wireless Mouse " becomes "Wireless Mouse" so your data groups correctly later.
- Select all the trimmed values in your new column.
- Press Ctrl+C to copy them.
- Select the first cell of your original product_name column.
- Right-click and select Paste Special, then choose Values to paste only the cleaned text (not the formula).
- Delete the helper column you created for TRIM.
Your product names should now have no extra spaces. Spot-check a few cells to confirm.
Next, fix the inconsistent category capitalization using Find & Replace.
- Press Ctrl+H to open the Find & Replace dialog.
- In the Find what field, type electronics.
- In the Replace with field, type Electronics.
- Click Options and check the Match case box so it only finds the lowercase version.
- Click Replace All.
- Repeat for the all-caps version: find ELECTRONICS and replace with Electronics.
- Repeat this process for every other category name you find with inconsistent capitalization (scroll through the category column to identify them all).
Check all category variants quickly
Select the entire category column and use Data > Filter to see a dropdown of all unique values. This reveals every variant you need to standardize.
Finally, standardize the date formats. PostgreSQL expects dates in YYYY-MM-DD format, so you need to convert all dates to match.
- Click on an empty cell in the first available column to the right of your data, in row 2.
- Type the following formula, replacing B2 with the cell reference for the first order_date value:
=TEXT(DATEVALUE(B2), "YYYY-MM-DD")
- Press Enter to confirm the formula.
- Copy this cell down to all rows by dragging the fill handle (the small square in the bottom-right corner of the selected cell).
What does this formula do?
DATEVALUE() takes a text string that looks like a date and converts it into an actual date number that Excel understands. It handles both MM/DD/YYYY and DD-Mon-YYYY formats automatically.
TEXT() then takes that date number and formats it as a text string in your chosen format: YYYY-MM-DD. This gives you consistent dates like 2024-03-15.
- Select all the newly formatted dates in your helper column.
- Press Ctrl+C to copy.
- Select the first cell of your original order_date column.
- Right-click and select Paste Special, then choose Values.
- Delete the helper column you created for the date conversion.
Spot-check several dates in your order_date column. They should all now follow the YYYY-MM-DD format (e.g., 2024-03-15).
Seeing #VALUE! errors in your date column?
This usually means Excel cannot parse the original date text. Check that the source cell actually contains a text date and not an empty cell or non-date value.
If your system uses a different date locale, DATEVALUE() may not recognize certain formats. Try formatting those cells manually or using a different approach for the problematic rows.
Help me fix #VALUE! errors in my DATEVALUE formula for mixed date formats.
Remove duplicates and handle missing values
Duplicate rows inflate your counts and totals. Missing values cause errors in calculations. You will remove both to ensure accurate analysis.
- Note your current row count by looking at the bottom-left of the Excel window or pressing Ctrl+End to jump to the last row of data.
- Click anywhere inside your data.
- Click the Data tab in the Excel ribbon.
- Click Remove Duplicates in the Data Tools group.
- In the dialog that appears, make sure all columns are checked.
- Click OK.
Excel displays a message telling you how many duplicates were removed and how many unique values remain.
What does Remove Duplicates check?
With all columns checked, Excel only removes rows where every single column value matches another row exactly. This prevents accidentally removing rows that share some values (like the same product name) but are actually different orders.
Now remove rows that have missing values in the quantity or unit_price columns.
- Click on the column header for your quantity column.
- Click Sort & Filter in the Home tab, then click Filter to add filter dropdowns to your headers.
- Click the filter dropdown arrow on the quantity column header.
- Uncheck Select All, then check only (Blanks) at the bottom of the list.
- Click OK to show only rows with missing quantity values.
- Select all the visible data rows (not the header) and right-click, then select Delete Row.
- Clear the filter by clicking the quantity filter dropdown and selecting Clear Filter From.
- Repeat the same process for the unit_price column: filter for blanks, delete those rows, then clear the filter.
- Verify your row count by pressing Ctrl+End to find the last row. You should have approximately 450 data rows remaining.
Row count seems too low or too high?
If you have significantly fewer than 450 rows, you may have accidentally deleted rows that had data. Press Ctrl+Z multiple times to undo and try the filter-and-delete process again.
Make sure you cleared all filters before checking your count. A filter still active will hide rows, making the count appear lower.
Help me figure out why my row count is wrong after removing duplicates and blanks.
Save the cleaned data as a new CSV file
You need to save your cleaned data as a separate file. This preserves your original messy file in case you need to go back and check something later.
- Delete any remaining helper columns you used during cleaning (TRIM columns, date formula columns). Only the original columns with corrected values should remain.
- Click File in the top menu.
- Click Save As.
- Navigate to your project folder (C:\Users\YourName\Documents\sales_project\ or wherever you saved the original file).
- In the File name field, type sales_cleaned.
- Click the Save as type dropdown and select CSV UTF-8 (Comma delimited) (*.csv).
- Click Save.
- If Excel asks about keeping the CSV format, click Yes.
Why UTF-8 CSV format?
UTF-8 is a universal character encoding that PostgreSQL handles natively. Saving as plain CSV sometimes uses a different encoding that can corrupt special characters during import. UTF-8 prevents these issues.
- Open File Explorer and navigate to your project folder.
- Confirm you see both your original messy CSV file and the new sales_cleaned.csv file.
Don't see the CSV UTF-8 option?
Older versions of Excel may not show "CSV UTF-8" in the Save as type dropdown. If you only see "CSV (Comma delimited)", select that option instead. For this project, the standard CSV format will still work with PostgreSQL in most cases.
Help me save my Excel file as UTF-8 CSV when the option is missing.
Your data is now clean and ready for serious analysis. Next up, you will load this cleaned data into a PostgreSQL database where you can run powerful SQL queries to uncover business insights.
Create a Database and Import Your Data
Your cleaned CSV is ready. The next challenge is putting that data somewhere you can ask questions about it using SQL.
PostgreSQL is a database system that stores structured data in tables. In this step, you will create a new database, define a table that matches your CSV columns, and import the cleaned data so you can run queries against it.
In this step, get ready to:
- Create a new database and table in pgAdmin.
- Import your cleaned CSV into the table.
- Verify the data imported correctly with SQL queries.
Create a new database and table
A database is a container that holds related tables. You will create one called ecommerce_sales and define a table inside it with columns that match your cleaned CSV.
- Switch back to pgAdmin in your browser.
- In the left-hand tree (the Object Explorer), expand your server by clicking the arrow next to PostgreSQL 18.
- Right-click the Databases node.
- Select Create, then Database....
- In the Database field on the General tab, type ecommerce_sales.
- Click Save.
Your new database appears in the tree under Databases. Now you need to open the Query Tool to create a table inside it.
- In the left-hand tree, click on ecommerce_sales to select it.
- Click Tools in the top menu bar, then select Query Tool.
What is the Query Tool?
The Query Tool is pgAdmin's built-in code editor where you write and run SQL statements. It connects directly to whichever database you had selected when you opened it.
- Define your sales table by pasting this SQL into the Query Tool:
-- Create a table to hold the cleaned sales data
CREATE TABLE sales (
order_id VARCHAR(50),
order_date DATE,
product_name VARCHAR(255),
category VARCHAR(100),
quantity INTEGER,
unit_price NUMERIC(10, 2),
region VARCHAR(100)
);
What does this SQL do?
This statement creates a table called sales with seven columns. Each column has a data type that tells PostgreSQL what kind of value to expect.
- VARCHAR(50) stores text up to 50 characters (for order IDs).
- DATE stores calendar dates (your YYYY-MM-DD values).
- INTEGER stores whole numbers (quantity).
- NUMERIC(10, 2) stores decimal numbers with two decimal places (unit price).
- Click the Execute/Run button (the play icon) in the Query Tool toolbar, or press F5.
- You should see a message in the Messages tab at the bottom that says the query was successful.
Seeing an error about the table already existing?
If you accidentally ran the statement twice, the table already exists. Run DROP TABLE sales; in the Query Tool first, then re-run the CREATE TABLE statement above.
Also check that you selected the ecommerce_sales database (not postgres) before opening the Query Tool. The database name appears in the Query Tool's title bar.
Still stuck? Help me fix my CREATE TABLE error in pgAdmin.
Import the cleaned CSV into your table
Now that the table structure exists, you will load your cleaned data into it using pgAdmin's Import/Export tool. This reads your CSV file and inserts each row into the sales table.
- In the left-hand tree, expand ecommerce_sales, then Schemas, then public, then Tables.
- Right-click the sales table.
- Select Import/Export Data....
What is Import/Export Data?
This dialog reads a file from your computer and loads its contents into the selected table. It handles the mapping between CSV columns and table columns automatically when the column names match.
- Set the toggle at the top to Import.
- Click the file selector and browse to your sales_cleaned.csv file (in your project folder).
- Set Format to csv.
- Turn on the Header toggle (your CSV has column headers in the first row).
- Confirm Delimiter is set to a comma (,).
- Click OK.
pgAdmin will display a success notification when the import finishes. Now verify that the data made it in.
- Return to the Query Tool (click the Query Tool tab at the top of pgAdmin, or open a new one from Tools).
- Check the total row count by running this query:
SELECT COUNT(*) FROM sales;
- You should see a count of approximately 450 in the results grid.
- Preview a sample of your data by running this query:
SELECT * FROM sales LIMIT 10;
You should see 10 rows with properly formatted dates (YYYY-MM-DD), integer quantities, and decimal prices. This confirms PostgreSQL read your CSV correctly and stored the values in the right data types.
Seeing 0 rows or an import error?
If SELECT COUNT(*) returns 0, the import did not load any data. Double-check that you set the toggle to Import (not Export) and that Header was turned on.
If you see an encoding error, make sure sales_cleaned.csv was saved as UTF-8 in Excel. Re-save the file using File, Save As, and select CSV UTF-8.
If dates show errors, confirm every date in your CSV uses the YYYY-MM-DD format. PostgreSQL is strict about date parsing.
Need more help? Help me troubleshoot my CSV import into PostgreSQL.
Your database is loaded and ready for analysis. Next up, you will write SQL queries to pull business insights from this data.
Write Analytical SQL Queries
Your cleaned data is now sitting in a PostgreSQL database, structured and ready to be questioned.
In this step, you will write SQL queries that extract real business insights from your sales data. These queries answer the kinds of questions hiring managers ask in data analyst interviews: revenue trends, top-performing products, and regional breakdowns.
In this step, get ready to:
- Write SQL queries that calculate revenue by month, by product, and by region.
- Export query results as CSV files for Tableau visualization.
Write a query to calculate total revenue by month
The first business question is: how does revenue change over time? A monthly revenue breakdown reveals seasonal trends and growth patterns.
- In the Query Tool for your ecommerce_sales database (the same one you used in the previous step), clear any existing queries in the editor.
- Type the following query to calculate total revenue grouped by month:
-- Calculate total revenue by month
SELECT
DATE_TRUNC('month', order_date) AS month,
SUM(quantity * unit_price) AS total_revenue
FROM sales
GROUP BY DATE_TRUNC('month', order_date)
ORDER BY month;
What does this query do?
DATE_TRUNC('month', order_date) chops each order date down to just the month (e.g., 2024-03-15 becomes 2024-03-01). This lets you group all orders from the same month together.
SUM(quantity * unit_price) multiplies quantity by price for each row, then adds up all those values within each month group. The result is your total revenue per month.
ORDER BY month sorts the results chronologically so you can see the revenue trend from earliest to latest.
- Click the Execute/Refresh button (the play icon) in the Query Tool toolbar to run the query.
- You should see results in the Data Output tab below, with a month column and a total_revenue column.
Not seeing any results?
Check that you are connected to the ecommerce_sales database, not the default postgres database. The database name is shown in the Query Tool tab title.
If you see an error about the sales table not existing, your Query Tool may be connected to the wrong database. Close the tab and reopen the Query Tool by right-clicking ecommerce_sales in the Object Explorer and selecting Query Tool.
help me debug my SQL query
Write a query to find the top 5 products by revenue
The next question is: which products drive the most revenue? Knowing your top sellers helps prioritize inventory and marketing spend.
- Clear the query editor and type the following query:
-- Find the top 5 products by total revenue
SELECT
product_name,
SUM(quantity * unit_price) AS total_revenue
FROM sales
GROUP BY product_name
ORDER BY total_revenue DESC
LIMIT 5;
What does this query do?
GROUP BY product_name groups all rows with the same product together, then SUM(quantity * unit_price) calculates the total revenue for each product.
ORDER BY total_revenue DESC sorts products from highest revenue to lowest. LIMIT 5 keeps only the top 5 results, giving you the best performers.
- Click Execute/Refresh to run the query.
- You should see 5 rows in the Data Output tab, each with a product_name and its total_revenue.
Seeing more than 5 rows?
Make sure LIMIT 5 is on its own line at the end of your query. If it is missing, the query returns every product in the table.
help me fix my top products SQL query
Write a query to calculate total revenue by region
The final question is: how does revenue break down geographically? Regional performance data helps identify strong markets and underperforming areas.
- Clear the query editor and type the following query:
-- Calculate total revenue by region
SELECT
region,
SUM(quantity * unit_price) AS total_revenue
FROM sales
GROUP BY region;
What does this query do?
GROUP BY region groups all orders from the same region together. SUM(quantity * unit_price) then totals the revenue within each geographic group.
This query has no ORDER BY because with only a few regions, you can easily scan the results without sorting. You will sort visually in Tableau later.
- Click Execute/Refresh to run the query.
- You should see one row per region in the Data Output tab, each with a region name and its total_revenue.
Seeing duplicate regions?
If you see the same region listed multiple times with different capitalization (e.g., "North" and "north"), your data cleaning in Step 2 may not have fully standardized the region column. Go back to your sales_cleaned.csv in Excel, fix the inconsistencies, re-import, and run the query again.
help me fix duplicate regions in my SQL results
✔️ Awesome, I've got everything!
Great. Double check that all three queries ran successfully and each produced results in the Data Output tab.
ⓧ I'd like to double check the full code
Here are all three queries together for reference:
-- Query 1: Calculate total revenue by month
SELECT
DATE_TRUNC('month', order_date) AS month,
SUM(quantity * unit_price) AS total_revenue
FROM sales
GROUP BY DATE_TRUNC('month', order_date)
ORDER BY month;
-- Query 2: Find the top 5 products by total revenue
SELECT
product_name,
SUM(quantity * unit_price) AS total_revenue
FROM sales
GROUP BY product_name
ORDER BY total_revenue DESC
LIMIT 5;
-- Query 3: Calculate total revenue by region
SELECT
region,
SUM(quantity * unit_price) AS total_revenue
FROM sales
GROUP BY region;
Export query results as CSV files for Tableau
Tableau Desktop Public Edition connects to text files like CSVs, not directly to PostgreSQL. You need to export each query result as a separate CSV file that Tableau can read.
Why export CSVs instead of connecting directly?
Tableau Desktop Public Edition only supports a limited set of data sources: text files, Excel, JSON, and a few others. It cannot connect directly to a PostgreSQL database.
Exporting query results as CSVs is actually a common workflow in professional data analysis. Analysts often share pre-aggregated data files with stakeholders who do not have database access.
- In the Query Tool, paste and run the first query (monthly revenue) again so the results appear in the Data Output tab.
- Click the Save results to file icon in the results pane (it looks like a download/save icon above the data grid).
- In the Save dialog, navigate to your project folder (C:\Users\YourName\Documents\sales_project\).
- Save the file as monthly_revenue.csv.
- Now paste and run the second query (top 5 products).
- Click the Save results to file icon again.
- Save the file as top_products.csv in the same project folder.
- Finally, paste and run the third query (regional revenue).
- Click the Save results to file icon.
- Save the file as regional_revenue.csv in the same project folder.
- Open File Explorer and navigate to your sales_project folder.
- Confirm you see three new CSV files: monthly_revenue.csv, top_products.csv, and regional_revenue.csv.
Quick check for valid data
Open one of the CSV files in Excel to confirm it has column headers in the first row and numeric revenue values below. If you see only one column with commas inside it, your CSV delimiter settings may be off.
Save results to file icon is grayed out?
The icon only becomes active after a query has been executed and results are visible in the Data Output tab. Make sure you clicked Execute/Refresh and see data in the grid before trying to save.
help me export query results from pgAdmin
You now have three analysis-ready CSV files sitting in your project folder. Next up, you will bring these into Tableau and transform the numbers into an interactive visual dashboard.
Build and Publish Your Tableau Dashboard
Your SQL queries extracted meaningful business insights from raw data. Three CSV files now sit in your project folder, each holding an answer to a key business question.
Numbers in a spreadsheet are hard to act on. A visual dashboard makes patterns obvious at a glance. In this step, you will use Tableau Desktop Public Edition to turn those CSV exports into interactive charts and publish them as a live, shareable dashboard.
In this step, get ready to:
- Connect your exported CSV files to Tableau and build three charts.
- Combine your charts into a single dashboard layout.
- Publish your dashboard to Tableau Public with a shareable URL.
Connect to your exported CSVs and build charts
Each of your three CSV files will become a separate data source in Tableau, powering its own chart on its own worksheet.
- Press the Windows key to open your search bar.
- Type Tableau Public and press Enter to open the app.
- You should see the Tableau Start page with the Connect pane on the left.
Start by connecting your monthly revenue data and building a line chart.
- On the Connect pane (left side of the Start page), under To a File, click Text File.
- Navigate to your project folder and select monthly_revenue.csv.
- Click Open.
- Tableau opens the Data Source page showing a preview of your data. Confirm you see the month and total_revenue columns.
- Click the Sheet 1 tab at the bottom of the screen to open a blank worksheet.
Now build a line chart showing revenue over time.
- In the Data pane on the left, find month and drag it to the Columns shelf at the top.
- Find total_revenue and drag it to the Rows shelf.
- Tableau automatically creates a line chart. If you see a bar chart instead, click the Show Me panel in the top right and select the line chart icon (continuous lines).
What does this chart show?
The line chart plots total revenue on the vertical axis against each month on the horizontal axis. Rising or falling trends tell you which months had the strongest sales performance.
You should see a line chart with revenue values plotted across your date range.
Next, connect your top products data and build a horizontal bar chart. Each chart uses its own data source.
- Click Data in the top menu bar.
- Select New Data Source.
- On the Connect pane, click Text File.
- Select top_products.csv from your project folder.
- Click Open.
- Confirm you see the product_name and total_revenue columns on the Data Source page.
- Click the New Worksheet tab (the plus icon at the bottom of the screen) to create a new sheet.
Now build the horizontal bar chart showing top products by revenue.
- Make sure top_products.csv is selected as the data source at the top of the Data pane.
- Drag total_revenue to the Columns shelf.
- Drag product_name to the Rows shelf.
- Click the sort descending icon on the toolbar to sort bars from highest to lowest revenue.
You should see a horizontal bar chart with your top 5 products listed by revenue, highest at the top.
Finally, connect your regional revenue data and build the third chart.
- Click Data in the top menu bar.
- Select New Data Source.
- Click Text File.
- Select regional_revenue.csv from your project folder.
- Click Open.
- Confirm you see the region and total_revenue columns on the Data Source page.
- Click the New Worksheet tab to create a third sheet.
Build a bar chart showing revenue by region.
- Make sure regional_revenue.csv is selected as the data source.
- Drag total_revenue to the Columns shelf.
- Drag region to the Rows shelf.
- Sort descending by revenue so the highest-performing region appears at the top.
You should now see a horizontal bar chart comparing revenue across regions.
Why separate data sources instead of one combined file?
Each CSV contains a different aggregation (monthly totals, product totals, regional totals). Keeping them as separate data sources avoids forcing unrelated dimensions into a single table.
This mirrors how analysts work with pre-aggregated query exports in practice.
Don't see your fields in the Data pane?
Make sure the correct data source is selected at the top of the Data pane. Click the data source name to switch between monthly_revenue.csv, top_products.csv, or regional_revenue.csv.
If a field shows as a string instead of a number, right-click it in the Data pane and select Change Data Type to set it to Number (Whole) or Number (Decimal).
Help me troubleshoot my Tableau data source connections and field types.
Combine sheets into a dashboard
A dashboard arranges multiple charts onto a single canvas so stakeholders can see the full picture at once.
- Click the New Dashboard tab at the bottom of the screen (the icon with a grid and a plus sign).
- In the Sheets pane on the left, you should see your three sheets listed.
- Drag Sheet 1 (your line chart) onto the dashboard canvas. It fills the full width.
- Drag Sheet 2 (top products bar chart) to the bottom-left area below the line chart.
- Drag Sheet 3 (regional chart) to the bottom-right area, next to Sheet 2.
Adjust the layout
If a chart appears too small, click its border on the dashboard canvas and drag to resize. The goal is a line chart spanning the full width on top, with the two bar charts side by side below.
Now add a title to your dashboard.
- In the left panel under Objects, find Text and drag it to the top of the dashboard canvas.
- In the text editor that appears, type E-Commerce Sales Performance Dashboard.
- Increase the font size to make it prominent.
- Click OK.
Your dashboard should now show all three charts with a title at the top. The line chart spans the full width, and the two bar charts sit side by side below it.
Publish to Tableau Public
Publishing makes your dashboard live on the web with a shareable URL. Anyone with the link can view and interact with your charts.
- Click Server in the top menu bar.
- Select Tableau Public.
- Click Save to Tableau Public.
- Tableau prompts you to sign in. Enter the email and password for the Tableau Public account you created earlier.
- In the workbook name field, type E-Commerce Sales Analysis.
- Click Save.
What happens during publishing?
Tableau Public creates an extract of your data and uploads everything to the cloud. Your browser opens automatically showing your live viz.
The data and dashboard are publicly accessible to anyone with the link.
- After publishing completes, your browser opens to show the live dashboard on Tableau Public.
- Copy the URL from your browser address bar. This is your shareable dashboard link for your portfolio or resume.
Publish failing or timing out?
Make sure you are connected to the internet. Tableau Public requires an active connection to upload your workbook.
If you see a sign-in error, double-check that you are using the same email and password from your Tableau Public profile (not a Tableau Cloud or Tableau Server account).
Help me troubleshoot publishing my workbook to Tableau Public.
Secret mission
Add Interactivity with Filters and Calculated Fields
Your dashboard shows the data, but it's static. Real analyst dashboards let viewers click a region and watch the other charts update instantly. They let viewers pick a product category and zoom in on exactly what matters to them. In this secret mission, you'll add calculated fields, filter actions, and interactive controls that turn your static report into a drill-down capable tool.
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely locally with no cloud costs. PostgreSQL runs as a free Windows service and your Tableau Public viz is hosted for free indefinitely. Decide whether to keep your resources running, pause them to come back later, or delete them entirely.
Resources you used:
- PostgreSQL 18 local server (running as a Windows service on port 5432).
- Tableau Public viz (hosted online as "E-Commerce Sales Analysis").
- Local project files (sales_project folder in Documents).
- Tableau Desktop Public Edition (installed application).
Keep everything running
No action needed. Choose this if you are still actively building or want to keep your dashboard live.
- PostgreSQL continues running as a Windows service. It uses minimal memory and no cloud costs.
- Your Tableau Public viz stays online indefinitely at its shareable URL.
- Your local CSV files remain in your sales_project folder.
Pause - I'll come back to this later
Stop running processes to free up memory. Your files and database stay intact for when you return.
- Press the Windows key, type services.msc, and press Enter.
- Find postgresql-x64-18 in the list.
- Right-click it and select Stop.
- Close Tableau Desktop Public Edition and pgAdmin.
- Your Tableau Public viz remains online. Your local files and database data are preserved.
- To restart later, open services.msc again, right-click postgresql-x64-18, and select Start.
Delete - I don't want to use this again
Remove all project resources and start fresh. This is permanent.
- Delete your local project files. Open Command Prompt and run:
rmdir /s /q "%USERPROFILE%\Documents\sales_project"
- Uninstall PostgreSQL 18. Open Settings, select Apps, then Installed apps. Find PostgreSQL 18 in the list, click the three-dot menu, and select Uninstall. This removes PostgreSQL, pgAdmin, and the Windows service.
- Uninstall Tableau Desktop Public Edition. In the same Installed apps list, find Tableau Desktop Public Edition, click the three-dot menu, and select Uninstall.
- Delete your Tableau Public viz. Go to your Tableau Public profile page in a browser. Hover over your "E-Commerce Sales Analysis" viz, click the More Actions icon, and select Delete This Viz.
Nice Work!
Nice Work!
Nice work! You just took a messy, real-world e-commerce dataset and transformed it into a polished, interactive dashboard published live on Tableau Public. That is the exact pipeline employers expect from a junior data analyst.
You've learned how to:
- Clean a messy dataset in Excel using TRIM(), Find and Replace, Remove Duplicates, and date standardization to produce analysis-ready data.
- Build a PostgreSQL database, define a table schema, import cleaned data with pgAdmin, and write analytical SQL queries using SUM(), GROUP BY, ORDER BY, and DATE_TRUNC() to extract business insights.
- Build a multi-chart Tableau dashboard and publish it to Tableau Public with a shareable portfolio URL.
- Secret Mission: Added interactive filters, calculated fields, and filter actions to create a drill-down capable dashboard.
Ready to quiz yourself?