Superset: How to group by month off a timestamp field from Redshift

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Superset: How to group by month off a timestamp field from Redshift



I am trying to show some trend over month in Superset from a table which has a timestamp field called created_at but have no idea how to get it right.


created_at



Here is what I am seeing



The SQL query generated from this is the followings:


SELECT
DATE_TRUNC('month', created_at) AT TIME ZONE 'UTC' AS __timestamp,
SUM(cost) AS "SUM(cost)"
FROM xxxx_from_redshift
WHERE created_at >= '2017-01-01 00:00:00'
AND created_at <= '2018-07-25 20:42:13'
GROUP BY DATE_TRUNC('month', created_at) AT TIME ZONE 'UTC'
ORDER BY "SUM(cost)" DESC
LIMIT 50000;



Like I mentioned above, I don't know how to make this work and 2nd question is why ORDER BY is using SUM(cost)? If this is a time-series, shouldn't it use ORDER BY 1 instead? I tried to change Sort By but to no avail.


ORDER BY


SUM(cost)


ORDER BY 1


Sort By




1 Answer
1



The query is saying:



I don't know what system you are using (Superset?) but try turning off Sort Descending. That might get it to sort by month instead.


Sort Descending





It is Superset. I have it in the title but will add it in the body as well. Turning off didn't help unfortunately. Still order by is the same.
– kee
2 mins ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS