'series is not periodic or has less than two periods (R in Tableau)

I am doing time series decomposition of beersales data using the R language in Tableau. I am trying to decompose the Trend, but when I drag created Trend calculation field (see. attached) there is an always error:

An error occurred while communicating with data source 'Analytics Extension'

Error Code:6116DD27
An error occurred while communicating with the Analytics Extension.
An error occurred while communicating with the Analytics Extension.
Error in stl(tmp_table, s.window = "periodic", robust = TRUE) : 
  series is not periodic or has less than two periods

However, when I run this code in RStudio, it works:

tmp_table <- ts(beersales$Sales, frequency=12);
stl_data <- stl(tmp_table, s.window='periodic', robust=TRUE);
stl_data$time.series[,2]

I followed the instruction given here, but I am still struggling to solve this issue, but still, no solution on the horizon, does anybody have any idea where is the problem?

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source