@here, Hi all!!!
I’m using the following sql script to obtain the top N from different categorical variables.
I need when I change the period of time, it changes the result I get.
So, I add in WHERE clause the condition for the date column.
But when I use the filter, the data doesn’t change.
Can someone help me with that? Thanks in advance!!
sql: SELECT field,
CASE
WHEN rank > {% parameter view1.param_rank_max %} THEN 'Other'
ELSE field
END AS topn
FROM
(
SELECT field,
cost,
dense_rank() over(ORDER BY cost DESC) as rank
FROM
(
SELECT {% parameter view1.analysis_variable %} AS field,
sum(cost) as cost
FROM table
WHERE {% condition view1.team %} team {% endcondition %} AND
{% condition view1.cost_center %} cost_center {% endcondition %} AND
{% condition view1.application %} application {% endcondition %} AND
{% condition view1.date_raw %} date {% endcondition %}
GROUP BY 1
)
)