Power Query Fill Down: How to Fix Missing Data Gaps
In this article
To perform a Fill Down in Power Query, select the column containing the gaps, go to the Transform tab, click the Fill menu, and select Down. This operation replaces every null value in a column with the last non-null value encountered above it, effectively "filling" the gaps in datasets where a category name is only listed once at the top of a group of related rows.
This feature is essential for cleaning data exported from legacy systems, accounting software, or pivot-style reports where merged cells were used. In a spreadsheet, a merged cell looks like one big block, but when imported into Power Query, only the first cell of that merged block contains the value, while all subsequent cells in that group are marked as null. Fill Down converts these fragmented records into a tabular format suitable for analysis, filtering, and pivot tables.
What You'll Need
- Microsoft Excel or Power BI Desktop.
- A dataset imported into the Power Query Editor.
- Columns containing
nullvalues (not empty strings or spaces) that need to be populated based on the value above them.
Step-by-Step
- Open the Power Query Editor: In Excel, go to the Data tab and select Get Data > Launch Power Query Editor. If your data is already loaded, double-click the query in the Queries & Connections pane. Note that labels and menu paths may vary slightly depending on your version of Excel or Power BI.
- Identify the Target Column: Locate the column where the data is "sparse." You will typically see a value in the first row of a group, followed by several rows that say
nullin italicized grey text. - Select the Column: Click the column header to highlight the entire column. You can select multiple columns by holding the Ctrl key if you need to apply the Fill Down operation to several fields simultaneously.
- Navigate to the Transform Tab: In the top ribbon, click on the Transform tab. This tab contains tools for modifying the existing data within your columns.
- Access the Fill Menu: Look for the Any Column group and click the Fill dropdown button.
- Choose Fill Down: Select Down from the dropdown options. Power Query will immediately scan the column from top to bottom. Every time it hits a
null, it will copy the value from the cell directly above it. It will continue doing this until it encounters a new, non-null value, at which point it will start filling down that new value for the subsequent nulls. - Verify the Results: Scroll through your data to ensure that the categories now align correctly with their respective rows. If the data looks correct, you can proceed to other transformation steps or click File > Close & Apply to load the data into your workbook or model.
Common Mistakes
One of the most frequent errors is attempting to Fill Down on cells that appear empty but are not actually null. In Power Query, there is a critical difference between a null value (which represents the absence of data) and an empty string (a cell that contains no text but is not technically null). If your cells contain empty strings, spaces, or hidden characters, the Fill Down command will do nothing because it only targets null values. To fix this, you must first right-click the column, select Replace Values, leave "Value To Find" empty, and enter null in the "Replace With" box (though in some versions, you may need to use the formula bar to ensure it is a true null constant).
Another mistake is applying Fill Down before sorting the data. Power Query processes rows in the order they appear. If you sort your data after filling down, the values will remain attached to the rows they were filled into, which is usually correct. However, if you sort the data before filling down, you may inadvertently move the "header" value away from the rows it was meant to describe, leading to incorrect data attribution. Always ensure your data is in the original, chronological, or grouped order intended by the source report before triggering the fill.
Users also sometimes forget that Fill Down is a destructive-style transformation in the sequence of steps. If you perform a Fill Down and then realize you filtered out some rows earlier in the process, those filtered rows are gone and cannot be "filled" back in. Always check your Filter steps in the Applied Steps pane to ensure you haven't removed the very values you are trying to propagate downward.
Tips
For more complex datasets, consider using Fill Up in conjunction with Fill Down. Fill Up works exactly like Fill Down but starts from the bottom of the table and moves upward. This is useful when the "category" value is listed at the end of a group rather than the beginning.
If you have multiple columns that need filling (for example, a "Region" column and a "Manager" column), you can select both columns by holding Ctrl before clicking Fill > Down. This saves you from creating two separate steps in your Applied Steps list, keeping your query cleaner and slightly improving performance on very large datasets.
To maintain data integrity, it is often helpful to add an Index Column before performing a Fill Down. Go to the Add Column tab and select Index Column > From 1. This creates a unique identifier for every row in its original order. If you ever need to sort your data to find errors and then return it to the original structure, the Index Column allows you to sort back to the exact sequence required for the Fill Down to make sense.
Troubleshooting
If the Fill Down operation does not seem to change any values in your column, the first thing to check is the content of the cells. As mentioned, the tool only works on null. If you see a blank cell but the word null is not there, the cell likely contains a space or an empty string. To resolve this: select the column, go to Transform > Replace Values, leave the first box blank, and type null in the second box. If that does not work, try selecting the column and using Transform > Format > Trim to remove any leading or trailing spaces that might be preventing the cell from being recognized as empty.
If the Fill Down is populating the wrong values, check the rows immediately preceding the gaps. If there is a stray value or a typo in a cell that should have been null, Power Query will treat that typo as the new "source" value and fill it down through the rest of the group. You will need to go back to a previous step in the Applied Steps pane, manually replace the incorrect value with null, and then let the Fill Down step re-run automatically.
In cases where the Fill Down creates an infinite loop or causes the query to hang, this is usually a sign of an extremely large dataset with very few non-null values. Try filtering the data to a smaller subset first to verify the logic works, or ensure that you are not performing the Fill Down on a calculated column that is constantly refreshing its own values based on the Fill Down result.
Frequently Asked Questions
Does Fill Down overwrite existing data?
No, Fill Down only replaces null values. Any cell that already contains data, including zeros or empty strings (unless replaced by null), will be ignored and left as is.
Can I use Fill Down on numbers and dates?
Yes, Fill Down works on any data type, including text, whole numbers, decimals, dates, and currency. It simply copies the value from the cell above regardless of the data type.
Is Fill Down a permanent change to my source file?
No, Power Query is a non-destructive tool. It creates a set of instructions (steps) to transform the data. Your original Excel or CSV source file remains completely unchanged.
What is the difference between Fill Down and Fill Up?
Fill Down takes a value and pushes it into the nulls below it. Fill Up takes a value and pushes it into the nulls above it. They are mirror images of the same logic.
Can I Fill Down based on a condition?
The standard Fill Down tool does not support conditions. If you only want to fill values under certain circumstances, you would need to create a Custom Column using an if statement or write a custom M function to handle the logic.