Sorting X Axis by Day of Week

Hi All, Is there a way to sort the X- Axis by Day of Week (Monday - Sunday)? I want to disregard any aggregate (count/count distinct) over the values to decide the sort order.

Hi @Tanisha_Shetty -

If you have the actual dates you can do this.

  1. Create a calculated field for the sorting.
    c_week_day
    extract('WD',dt)

  2. Go to “sort options” in your x-axis dimension and sort by c_week_day (max/min) ascending.

If for some reason you don’t have actual dates but strings with the day of the week. You can do something like this but in reverse, then use the calculated field with step 2.

ifelse(
extract('WD',dt)=1,'Sunday',
extract('WD',dt)=2,'Monday',
extract('WD',dt)=3,'Tuesday',
extract('WD',dt)=4,'Wednesday',
extract('WD',dt)=5,'Thursday',
extract('WD',dt)=6,'Friday',
extract('WD',dt)=7,'Saturday',null)

Hi @robdhondt,
I tried both methods. Using them I was able to fetch weekdays from date but by default weekdays are appearing in ‘z-a’ order, not from (Monday - Sunday).

image

@Raghu
Did you find an solution to this issue

@deepa.singh

To sort your days properly, you need a calculated field that represents the day of the week as an integer, e.g. 1 for Sunday, 2 for Monday, etc.

Instead of sorting by Day Name, select “Sort options”.
image

Select the integer field that you want to sort by (e.g, Day of Week) and set the aggregation to Min.
image

Bar chart when sorted by Day Name:

When sorted by Day of Week:

@David_Wong

You are genius
Thanks