Power Query: Faster Fiddly Fill Down
8 July 2020
Welcome to our Power Query blog. This week, I look at a more efficient method to solve last week’s fill down problem.
I start with the same data as last week.

I would like to get this into a more standard format, by filling down the tent and awning types. I begin by extracting my data to Power Query by using the ‘From Table’ option on the ‘Get & Transform’ section of the Data tab.

Instead of creating a new column, as I did last week, I am going to use ‘Replace Values’ to fix my data in the Awning column. I start by creating a ‘Replace Values’ step. At this point it doesn’t matter what I am replacing, I just need to have the format of the M code I will need.

I have ticked the box in the ‘Advanced options’ to ‘Match entire sell contents’. The M code I have generated is:
= Table.ReplaceValue(#"Changed Type","First","Second",Replacer.ReplaceValue,{"Awning"})
If I hadn’t matched the entire cell contents, then the Replacer parameter would have been ReplaceText instead of ReplaceValue. Also:
- instead of First, I am going to use each[Awning], i.e. the current Awning value
- instead of Second, I am going to use a condition: this will be the same condition that I used in last week’s conditional column, which, in M code, is:
each if [Tent] = null then [Awning] else “Don’t Fill”.
This all means, keep the Awning value if Tent is null, otherwise put ‘Don’t Fill’ in the Awning value. The M code for my step is now:
= Table.ReplaceValue(#”Changed Type”, each [Awning], each if [Tent] = null then [Awning] else “Don’t Fill”, Replacer.ReplaceValue,{"Awning"})

When I click on the check mark to execute my code I see my results:

Similarly to last week, I can select Tent and Awning and fill them both down.

All I need to do now, is replace ‘Don’t Fill’ with null in Awning.

My columns are now filled correctly. Next time, I will look at another method which copies a column to get the required result.
Come back next time for more ways to use Power Query!