Sort Bar Gauge by number column

I have a query like this with postgres as backend:

select distinct 
obsolete_date as time,
software_product_version_name as metric,
obsolete_date::date - current_date as days_to_expire
from evergreen
where current_date < obsolete_date
order by 1,3

How can i sort by days_to_expire ? So I have the earliest days on top of the graph, I tried the transformations but I cannot select that column in the SORT BY transformation

not sure what you mean by earliest date but what if you just did

order by 3 desc

that doesn’t work, it is a time series type and i need to order by time too, I mean on the right side of the chart you can see many values as such: 52 days. I want them ordered from lowest number to highest number. The order now seems to be done by the way the columns appear in the underlying table from left to right, I would like to order the products by the number of days.

this is the table of the data

1 Like

How about add a transform to convert that columm to a number and the timw to time type them another transform to sort by the time field and the converted now numeric value

hi, in the first picture there is an alias called days_to_expire , that column is already an integer, not float. Do i need to make float ? the days you see there is just a modification in the standar options

furthemore, the field type days_to_expire does not even show in the transform values to choose, not sure why, for example if i start typing days_to_expire in the transform tab, nothing populates

pic of the data types in the postgres backend, this is exactly how i want the order to be displayed in the gauge, but grafana is making this table a wide table, and the column days_to_expire becomes the values, so it doesn’t exist

1 Like