// Continue from here to calculate the forecast#"Added Custom4" = Table.AddColumn(SortedTable, "Forecast", each let // Find values for 7 days prior and multiply by 0.4 ActualTotal7 = List.First(List.Select(SortedTable[Actual Total], each [Date] = Date.AddDays([Date],-7))) * 0.4, // Find values for 14 days prior and multiply by 0.3 ActualTotal14 = List.First(List.Select(SortedTable[Actual Total.7], each [Date] = Date.AddDays([Date],-14))) * 0.3, // Find values for 21 days prior and multiply by 0.2 ActualTotal21 = List.First(List.Select(SortedTable[Actual Total.1], each [Date] = Date.AddDays([Date],-21))) * 0.2, // Find values for 28 days prior and multiply by 0.1 ActualTotal28 = List.First(List.Select(SortedTable[Actual Total.2], each [Date] = Date.AddDays([Date],-28))) * 0.1, // Sum the results to get the final forecast Forecast = ActualTotal7 + ActualTotal14 + ActualTotal21 + ActualTotal28 in Forecast),to this:let
Question
// Continue from here to calculate the forecast#"Added Custom4" = Table.AddColumn(SortedTable, "Forecast", each let // Find values for 7 days prior and multiply by 0.4 ActualTotal7 = List.First(List.Select(SortedTable[Actual Total], each [Date] = Date.AddDays([Date],-7))) * 0.4, // Find values for 14 days prior and multiply by 0.3 ActualTotal14 = List.First(List.Select(SortedTable[Actual Total.7], each [Date] = Date.AddDays([Date],-14))) * 0.3, // Find values for 21 days prior and multiply by 0.2 ActualTotal21 = List.First(List.Select(SortedTable[Actual Total.1], each [Date] = Date.AddDays([Date],-21))) * 0.2, // Find values for 28 days prior and multiply by 0.1 ActualTotal28 = List.First(List.Select(SortedTable[Actual Total.2], each [Date] = Date.AddDays([Date],-28))) * 0.1, // Sum the results to get the final forecast Forecast = ActualTotal7 + ActualTotal14 + ActualTotal21 + ActualTotal28 in Forecast),to this:let
Solution
// To continue from here and calculate the forecast, add a new column called "Forecast" to the SortedTable. Use the "each" keyword to define a function that performs the following steps:
-
Find the value for 7 days prior by selecting the first value from the SortedTable[Actual Total] column where the [Date] is equal to Date.AddDays([Date], -7). Multiply this value by 0.4 and assign it to the variable ActualTotal7.
-
Find the value for 14 days prior by selecting the first value from the SortedTable[Actual Total.7] column where the [Date] is equal to Date.AddDays([Date], -14). Multiply this value by 0.3 and assign it to the variable ActualTotal14.
-
Find the value for 21 days prior by selecting the first value from the SortedTable[Actual Total.1] column where the [Date] is equal to Date.AddDays([Date], -21). Multiply this value by 0.2 and assign it to the variable ActualTotal21.
-
Find the value for 28 days prior by selecting the first value from the SortedTable[Actual Total.2] column where the [Date] is equal to Date.AddDays([Date], -28). Multiply this value by 0.1 and assign it to the variable ActualTotal28.
-
Sum the values of ActualTotal7, ActualTotal14, ActualTotal21, and ActualTotal28 to get the final forecast. Assign this sum to the variable Forecast.
Finally, return the value of Forecast as the result of the function.
The updated code should look like this:
"Added Custom4" = Table.AddColumn(SortedTable, "Forecast", each let ActualTotal7 = List.First(List.Select(SortedTable[Actual Total], each [Date] = Date.AddDays([Date],-7))) * 0.4, ActualTotal14 = List.First(List.Select(SortedTable[Actual Total.7], each [Date] = Date.AddDays([Date],-14))) * 0.3, ActualTotal21 = List.First(List.Select(SortedTable[Actual Total.1], each [Date] = Date.AddDays([Date],-21))) * 0.2, ActualTotal28 = List.First(List.Select(SortedTable[Actual Total.2], each [Date] = Date.AddDays([Date],-28))) * 0.1, Forecast = ActualTotal7 + ActualTotal14 + ActualTotal21 + ActualTotal28 in Forecast)
Similar Questions
Outline the elements of forecasting
FORECAST.ETS.CONFINT
what do you mean by forecasting? Explain its steps
Predicted demand of a product for the current month = 4,064 unitsActual demand of the product for the current month = 4,806 unitsSmoothing constant = 0.2Required: Forecast the demand of the product (in units) for the next month?
// Continue from here to calculate the forecast#"Added Custom4" = Table.AddColumn(SortedTable, "Forecast", each let // Find values for 7 days prior and multiply by 0.4 ActualTotal7 = List.First(List.Select(SortedTable[Actual Total], each [Date] = Date.AddDays([Date],-7))) * 0.4, // Find values for 14 days prior and multiply by 0.3 ActualTotal14 = List.First(List.Select(SortedTable[Actual Total.7], each [Date] = Date.AddDays([Date],-14))) * 0.3, // Find values for 21 days prior and multiply by 0.2 ActualTotal21 = List.First(List.Select(SortedTable[Actual Total.1], each [Date] = Date.AddDays([Date],-21))) * 0.2, // Find values for 28 days prior and multiply by 0.1 ActualTotal28 = List.First(List.Select(SortedTable[Actual Total.2], each [Date] = Date.AddDays([Date],-28))) * 0.1, // Sum the results to get the final forecast Forecast = ActualTotal7 + ActualTotal14 + ActualTotal21 + ActualTotal28 in Forecast),to this:let
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.