Sorting a Stacked Barchart

I am trying to sort the my chart so that the Red (disagree) is on the far left, then gray, then light to dark green. Does anyone know how to do this? On normal charts I can add a hidden sort dimension, but this situation won’t let me do that.

Hi Benjamin,

Yes, it’s possible. For categorical values that are often used as pivots, I create an order field in LookML:

dimension: recommend_choice_order {
  type: number
  hidden: yes
  sql: CASE 
         WHEN ${recommend_choice} = 'Disagree' THEN 1
         WHEN ....... THEN 2
         ELSE 8
       END ;;
}

And then use parameter order_by_field in your categorical dimension:

dimension: recommend_choice {
  order_by_field: recommend_choice_order
}
1 Like