0
votes

What is the most effective procedure or equivalent for "head" & "tail" in Tableau if you are try to isolate the last or first items of an vector? The known procedure e.g. in R is easy if you are looking for an average of the last 10 numbers: mean(head(x, 10)) or mean(tail(x, 10)). I try to find a solution in Tableau with LOD "max" & "min" but "show me the first 10 min items"?! No chance!

1
First() and Last()??Sam M
I'm looking for the equivalent of mean(head(x, 10)). avg(first(x, 10)) - no, thats no solution.Teletubbi-OS X
Where are these vectors you are talking about? Are you talking about rows in a database table? Tableau queries relational tables where data row order is undefined. Or are you talking about partitions of the query results that you examine with table calcs, such as when you call R from Tableau?Alex Blakemore
x is the vector and contains n values - e.g. integers. With "equivalent" I try to explain that there is for the same task an other wording/syntax in Tableau, Pyrhon, C++ ... To find the first 10 numbers from x in R: head(x, 10), and what is the equivalent for that in Tableau. Ok? And for the average: mean(head(x, 10))Teletubbi-OS X

1 Answers

0
votes

If you are talking about table calculations, then you can use the WINDOW_XXX() functions -- such as window_sum(sum(x), 1, 10) or window_avg(sum(x), size()-9, size())

Table calcs operate on the aggregated query results returned from the data source, hence the aggregation function sum() around the field x.

It might be simpler to learn to use Top N filters instead table calcs, depending on what problem you are trying to solve.