Create your own
Lesson illustration

Cleaning Financial Data: Missing Values and Data Types

Hello! Welcome back to our course on financial data visualization.

In our last lesson, we focused on structuring and formatting data in Excel, creating a solid foundation for analysis. We learned that well-organized tabular data is essential for Excel's powerful features.

Today, we address the critical next step: data cleaning. The most beautiful chart is misleading if built on flawed data. In the world of data analysis, the principle of "garbage in, garbage out" is absolute. This lesson will teach you how to clean financial data by handling missing values and correcting data types, ensuring your analysis is accurate and reliable.

By the end of this 60-minute lesson, you'll be able to identify and fix the most common data quality issues you'll encounter with financial data, using both manual Excel techniques and the more powerful, automated approach of Power Query.

Messy Data in Excel Spreadsheet
Real-world data is often messy. This image shows a typical scenario with missing values, incorrect entries, and formula errors—all issues we'll learn to fix today.

1. The Core Principles of Clean Data

Before we jump into the "how," let's quickly establish our goal. What does "clean" data actually look like? In short, clean data is accurate, complete, and uniform. For financial analysis, this is non-negotiable.

  • Accuracy: A stock price of $150.25 must not be recorded as 15025 or as text.
  • Completeness: A time series with missing dates can break calculations for returns or moving averages.
  • Uniformity: All values in a column should have the same data type (e.g., all numbers or all dates) and use the same units.

To formalize this, let's look at a brief guide that defines these components.

How to Clean Data in Excel: A Beginner's Guide

This article from DataCamp clearly defines the components of high-quality data. Understanding these concepts will help you recognize what you are aiming for when you clean a dataset.

Please read the short introductory section titled 'What Are the Components of Clean Data?'. Focus on the definitions of Accuracy, Completeness, and Uniformity.

2. Handling Missing Values

Missing data is one of the most common problems you'll face. In a financial context, a blank cell in a 'Closing Price' column could mean the market was closed, the data failed to load, or it's simply an error. How you handle it has a direct impact on your analysis.

Manual Techniques for Filling Blanks

For one-off cleaning tasks, Excel provides a handy way to find and fill all blank cells at once. The main strategies are to either remove the incomplete record or to impute a value (i.e., make an educated guess).

Common imputation methods for numerical data include filling with the:

  • Mean (Average): A good general-purpose choice.
  • Median (Middle Value): Better if your data has outliers that would skew the average.
  • A specific value: Such as 0 or a text placeholder like "N/A".

The following video demonstrates the classic Excel method for finding blank cells and applying these imputation techniques.

Missing Value Treatment in Excel | Data Cleaning Using Excel Ep 6 | IvyProSchool

This video from IvyProSchool provides a clear, step-by-step walkthrough of how to find and fill missing values using Excel's built-in tools.

Watch the segment from 07:56 to 15:21. It demonstrates how to: Select all blank cells at once using the 'Go To Special' dialog (Ctrl+G). Fill the selected blanks with the Mean (Average) of the column. Repeat the process using the Median and Mode. Pay close attention to the Ctrl+Enter shortcut, which applies a formula to all selected cells simultaneously.

While powerful, these manual imputation methods are best for simple datasets. For financial time-series data, more advanced techniques like 'forward fill' (using the last known value) are often preferred, which we will see Power Query can handle easily.

3. Correcting Data Types

Another frequent issue, especially when importing data from CSV files or the web, is incorrect data types. For example, Excel might see a date like "2023-10-25" as text, or a price like "1,250.50" as a string of characters instead of a number. This will prevent you from performing any mathematical operations or chronological sorting.

Basic Fixes for Numbers and Dates

Excel has built-in tools to help you convert data back to its proper format.

How to Clean Data in Excel: A Beginner's Guide

The DataCamp article we looked at earlier also provides a straightforward guide to fixing the most common data type problems directly in your worksheet.

Please read the section titled 'Numerical and Date Fixes in Excel'. This covers the standard methods for ensuring your numbers are treated as numbers and your dates are treated as dates.

As a quick check, especially when your charts look wrong, always ask yourself these two questions (as suggested in the article "how to make stock graph in excel: step-by-step" you might have seen referenced):

  1. Are my date cells real dates? (Check the format in the 'Home' > 'Number' group).
  2. Are my price cells truly numeric?

If not, your calculations and charts will fail.

4. The Automated Approach: Cleaning with Power Query

Manual cleaning is useful, but what if you download market data every week or every month? Repeating these steps is tedious and error-prone. This is where Power Query becomes essential.

You've already seen Power Query used for importing data. Its real strength lies in creating a repeatable sequence of cleaning and transformation steps. You build the cleaning process once, and then simply click "Refresh" to apply it to new data.

This is particularly relevant to you as you progress towards Power BI, as the Power Query Editor is identical in both Excel and Power BI.

How To Import & Clean Messy Accounting Data in Excel | Use Power Query to Import SAP Data

This excellent tutorial by Leila Gharani demonstrates cleaning messy financial data using Power Query. It showcases solutions to problems that are very difficult to solve manually.

Please watch these two key segments: Correcting Number Formats (09:09 - 10:14): This is a critical skill. Pay close attention to how she uses 'Change Type' > 'Using Locale' to correctly interpret numbers from different regions (e.g., where a comma is a decimal separator). Handling Missing Data & Transforming (15:44 - 19:08): This second example shows other powerful techniques like removing nulls, filtering, and using 'Fill Down' to populate empty cells with the value from the cell above—perfect for cleaning up ledger-style reports. Notice how every action is recorded in the 'Applied Steps' pane, creating an automated workflow.

Power Query's ability to handle different regional number settings ('locales') and to fill data down a column are just two examples of how it automates complex cleaning tasks that would be a major headache to do manually.

Test your understanding!

You need to analyze historical stock prices for a German company. The data, downloaded as a CSV, uses a period (.) as the thousands separator and a comma (,) as the decimal separator (e.g., 1.250,75 for one thousand two hundred fifty and 75 cents). If you try to sum this column in Excel, you get 0.

Which tool and specific feature would you use to fix this problem for a report you need to update monthly?

Show answer

The best tool is Power Query. Specifically, you would use the Change Type > Using Locale feature. You would tell Power Query that the data type is a Decimal Number and the Locale is "German (Germany)". This instructs Power Query to correctly interpret the . as a thousands separator and the , as a decimal point. Because this step is saved in the query, you can simply refresh it next month, and it will automatically apply the correct conversion to the new data.

Conclusion

Great job! Today you've learned one of the most practical and important skills in data analysis: how to take messy, real-world data and make it clean, reliable, and ready for analysis. This skill separates casual spreadsheet users from serious analysts.

Here are your key takeaways:

  • Clean data is the goal: Always aim for data that is accurate, complete, and uniform.
  • Handle missing values deliberately: You can find blanks using Go To Special (Ctrl+G) and then decide whether to delete the records or impute values using the mean, median, or a placeholder.
  • Verify your data types: Ensure numbers are numbers and dates are dates to enable calculations and sorting.
  • Automate with Power Query: For any cleaning task you'll do more than once, Power Query is the superior tool. It saves your steps, handles complex transformations, and ensures consistency.

Now that your data is structured, formatted, and clean, you are truly ready to begin your analysis. In our next lesson, we will use Excel formulas to calculate key financial metrics such as simple returns and moving averages, turning our clean data into actionable information.

Can't find a good explanation? Sign up and we'll make it for you

Sign up