Forum Discussion

kev_sav's avatar
kev_sav
Frequent Visitor
2 years ago
Solved

Sorting issue in bar chart when a parameter is used to switch the axis

My data set has 4 columns (3 dimensions & 1 metric):

  • Quarter (String datatype)
  • Month (Date datatype)
  • Week (Date datatype)
  • Revenue (A numeric metric)

 

I have created a vertical bar chart where the Y axis is revenue(metric) and the X axis is either a Quarter, Month or a Week based on the single select slicer (In other words I have created a parameter named “Date Type” consisting of “Quarter”, “Month” & “Week” to give the end user the flexibility to aggregate and choose the type of date they want to see on the X axis).

 

I’m facing issue in sorting this bar chart. I want the chart to be sorted in ascending order based on the “Date Type” parameter value selected and not the revenue metric.

It seems to be working fine when “Month” & “Week” values are selected in the parameter, but the sorting goes for a toss when I select “Quarter”.

 

I assume this is because the parameter is made up of 2 different data types (string and date), but unable to find a solution. Kindly help.

 

Here are images for your reference:

 

1. Sorted correctly in ascending order by Month:

 

2. Sorted incorrectly (This is sorted in descending order by Revenue) – Ideally this should also have been sorted in ascending order by Quarter:

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi kev_sav

    Based on your descriprtion, you should have a calendar table, you can create a new column in calendar table.

    Year&Quarter = YEAR([Date])*100+QUARTER([Date])

    Then check the quarter column and select sort by the Year&Quarter column.

    Then reput the field to the x-axis, then it can work.

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi kev_sav

    Based on your descriprtion, you should have a calendar table, you can create a new column in calendar table.

    Year&Quarter = YEAR([Date])*100+QUARTER([Date])

    Then check the quarter column and select sort by the Year&Quarter column.

    Then reput the field to the x-axis, then it can work.

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.