Forum Discussion
Anonymous
8 years agoNot applicable
Calculate Exponential Smoothing Forecast on Query Editor
Hi all, I have been searching high and low for a way to populate a column of forecasted values using DAX. Other than forecasting by moving average, I have not been able to find any methods to perform...
v-jiascu-msft
8 years agoMicrosoft Employee
Hi Anonymous,
The Exponential Smoothing is a little complicated. There could be a solution here by R.
# 'dataset' holds the input data for this script
temp <- dataset
temp$Date <- as.Date(temp$Date, '%Y-%m-%d')
es <- c()
minDate <- temp$Date[1]
ds_length <- length(temp$Date)
for (index in c(1:ds_length)) {
if (temp[index,1] == minDate) {
st <- temp[index, 3]
}
else {
st <- 0.2 * temp[index, 3] + (1 - 0.2) * es[index - 1]
}
es[index] <- st
}
temp$es <- es
Best Regards,
Dale
Mohamed-Ashraf
6 years agoNew Member
Could you please clarify how to make this code reusable to just replace parameters (Date, Value)?
when I executed this code I received an error
(Error in if (temp[index, 1] == minDate) { :
missing value where TRUE/FALSE needed
Execution halted
)