Using order_by_field with dynamic dimensions using parameters

I defined a dynamic dimension that I use as filter, as described examples here and here.

For example one option might be "date" and another might be "version". 

I want to order version not with default sort but using another dimension (a number based on version), because i.e. v0.9 should come before v0.10 etc. Normally I would do this using order_by_field. 

However, clearly if the user selects "date", I want to sort using date and not version.

dimension: plotby {
    label: "dynamic axis"
    label_from_parameter: axis_selector
    type: string
    sql:
    {% if axis_selector._parameter_value == 'date' %}
      ${date}
    {% elsif axis_selector._parameter_value == 'version' %}
      ${version}
    {% endif %};;
    order_by_field: version_ordering_field
  }

The code above results in bad ordering if the user selects date.

How can I order both version and date correctly in this case?

0 0 162
0 REPLIES 0
Top Labels in this Space
Top Solution Authors