Forum Discussion
Fill null values with latest data available
Hello,
I am trying to fill missing values in a certain period with the latest data that is available. I have a survey that is filled in per store. However, not every store is visited every month. This means that when a store is for example visited in June but not in July, that I don’t have data for July. My goal is to, when no data is available for a certain month, copy the data from the previous (or latest available) month to the months I don’t have data for.
It is also possible that a store is visited more than once a month. Therefore, I select the max date per period, by pivoting the period column as follows:
This results in the following outcome.
I want to fill the “null”-values here with the next value in the corresponding row that has no “null”-value. For the first row, for example, I want to use the survey results (=distribution) from 6/15/2021 in period 7 (=2021P07) since I don’t have results for period 7 itself. Afterwards, I want to unpivot the period columns and then I think my problem is solved. However, I have no idea how I can do this.
Has anyone an idea?
Thank you in advance!
3 Replies
- lbendlinSuper User
Power Query has a function for this. Right click the column header, select "Fill..." then "Down"
- neleFrequent Visitor
Thank you for your response. I know the "Fill" function, however, I want to fill rows. In my example, I want to use data from column "2021P06" in column "2021P07". Afterwards, I want to unpivot these columns. When there are null-values in the column, I loose these rows.
- lbendlinSuper User
Please provide sample data in usable format (not as a picture) and show the expected outcome.