redash
redash copied to clipboard
Hey, why i can not sort by Row Lable
Can not sort by Row Lable. In this image sort by month_formatted can not work. It's sort by alphabet.
I've run into this before. Redash only supports simple sorting afaik, so what I did to sort myself was add a custom ORDER BY clause and tell redash not to sort values. In my case this was a list of 3 categories in one instance and the days of the week in another, so pretty easy to build the sort order, but maybe you'll need to order by a specific column in your case?
A part of my query. I tried "ORDER BY" month_formatted. But it is not working @guidopetri.
SELECT
TO_CHAR(DATE_TRUNC('week',created_at)::date,'YYYY-MM-DD') AS month_formatted,
CASE EXTRACT(DOW FROM created_at)
WHEN 1 THEN '1. Monday'
WHEN 2 THEN '2. Tuesday'
WHEN 3 THEN '3. Wednesday'
WHEN 4 THEN '4. Thursday'
WHEN 5 THEN '5. Friday'
WHEN 6 THEN '6. Saturday'
ELSE '7. Sunday'
END AS day_of_week,
SUM(activity) AS active_company
FROM CTE
WHERE created_at >= '2023-01-01'
GROUP BY 1,2
ORDER BY 1 DESC