July 11, 2016
I have created a query that picks up source data for the period from Feb 2019 to July 2020. Part of the query is to un-pivot the data so that the months appeared as columns. Doing this creates column fields with a null value. I then selected the month columns and replaced the null values with zero. This also changed the type to decimal numbers. I then added a field that summed up the Feb 2019 to July 2020 fields.
I have now updated the source data to include August 2020. How do I update the query so that it automatically includes August, replaces the null values with zero, changes the field type to decimal numbers and includes it in the calculated field so that it sums up Jan 2019 to August 2020?
October 5, 2010
July 11, 2016
Please find the workbook attached. The query is returned in the table in the Sales_Data sheet. The source data is in the Sales sheet.
I created the report initially to look at the periods form Jan 2020 to July 2020. I then added August 2020 data. If you look at the Sales_Data sheet you can see that column Q has returned the numbers for 01/08/20. However in the query there is a step "Replaced Value". This step is to replace any null values in the month columns with zero. If you look at this step in the query you can see that it only picks up the months Jan to July. Similarly in the step "Inserted Sum" I want to sum up all of the months from Jan to August but again it only includes up to July.
What I want to find out is how to I get these steps to pick up any new months added or is there an alternative method to do what I need?
July 16, 2010
In the attached file you can see I created a dynamic list of the columns called 'ColsToAverage' and used that to create the Average column using this code:
= Table.AddColumn(#"Replaced Value", "Average", each List.Average(Record.ToList(Record.SelectFields(_, ColsToAverage))), type number)
I hope that helps.