The functions which begin with „WINDOW_...“ are also common used in Tableau.
Remember!
The “WINDOW_” function stays for the offset in data set, so-called WINDOW. It can look like this:
1) You can see the “WINDOW” clearly because of separation line between rows:
2) You limit the “Window” by giving the information about the first and the last row number. In this case, you give Tableau the information about the data offset.
Let's have a look at the example with WINDOW_SUM
I created a sample with data from Superstore.
I would like to have a total sum of Sales in every row. In order to do this I created a calculation field:
WINDOW_SUM(SUM([Sales]), FIRST(), LAST())
With this formula I said to Tableau:
“Hey Tableau, calculate the total sum of sales from the first till the last row in the data set”
And this is the result:
Tableau wrote the result (total sum of Sales) in every row.
As another option you can cumulate the result in each row and beginn from any row you wish. For this you need this formula:
WINDOW_SUM(sum([Sales]),FIRST()+3,0)
Try out follow combination and see what happens with data:
- WINDOW_SUM(sum([Sales]),FIRST()-3,0)
- WINDOW_SUM(sum([Sales]),FIRST()-3,5)
- WINDOW_SUM(sum([Sales]),FIRST()-3,LAST()-2)
- WINDOW_SUM(sum([Sales]),FIRST()+3,LAST()-2)
WINDOW_SUM(sum([Sales]),3,5)
You can run different operations and calculate the average, minimum, maximum, standard deviation etc.. It depends on, what are you going to use at the end of the function WINDOW_.....
The point is that you understand the logic of this function. I hope, I could help you understand this logic with this blog.
You can find here the blog article as an example of using of this function:
Here you can find explanation and examples to other windows functions
Best regards
Kommentare
Kommentar veröffentlichen