Hi, there's an option to filter by 'Last 12 months...
# gooddata-cloud
e
Hi, there's an option to filter by 'Last 12 months' in dashboard-level and insight-level filters but I can't find it in the metric-level date filter. Does anyone know how to filter a visualization metric by 'Last 12 months'?
j
Hi Emir, You can use a FOR PREVIOUS clause in your metric to filter for the last 12 months. It would look something like this:
Copy code
SELECT {metric/revenues} FOR Previous({attribute/month} , 12)
e
Hi Joseph, thanks for the reply!! I'm wondering if there is a way to do it without having to create a new metric since there's already a feature to apply date filter on a metric when using it in an insight
To give a better context, I want to have 4+ table columns of the same metric with different date filters like: • count: original metric • count for the last month • count for the last x month • count for the last y month • ...
j
If that is your use case, the best option is to create 4 separate metrics. You would need to filter at the metric level to ensure the filtering was explicit for each metric. The vis filter itself will only allow for one filter in this context.
e
Hi again Joseph, I've created a new metric as you suggested using
FOR Previous
but cannot see it in the visualization editor (Analyze view). Do you know why that happens?
j
If they are the two unrelated data items hidden in your screenshot, then it is an issue with the LDM. You may need to use a "BY" clause to connect the datasets you are trying to slice by.
e
Hi Joseph, it turned out to be a small mistake I made in the MAQL query. Thanks a lot for your time and support, I appreciate it!