How to sort differently

Hello! Seeking assistance in sorting my fields differently. I am trying to sort by tenure using a “ifelse” calculated field but am running into error messages.

ifelse(
{tenure}='Less than 1 year', <1,
{tenure}='1-2 years', 1-2,
{tenure}='3-4 years', 3-4,
{tenure}='5-6 years', 5-6,
{tenure}='7-9 years', 7-9,
{tenure}='10+ years', 10+
)

Hi @quicksightuser908908
what kind of error message are you facing?
BR

On line 2, “the syntax of the calculated field expression is incorrect. Correct the syntax and choose Create again”

Did you try to write “<1” instead of <1 and ff

Yes so when I enter it just for the “<1” it highlights line 8 with the same error message, and if I try adding quotes around all it highlights the entire equation with the same error message. image

Can you try
…{tenure}=‘7-9 years’, ‘7-9’, ‘10+’)

Sure, same error unfortunately
image

There is something wrong

Thank you, fixed that and now it does accept the new calculated field, but it doesn’t show up correctly on my bar chart (I want it to sort as <1, 1-2, 3-4, etc.).

Under sort options I select the new calculated field but it doesn’t change the order on the y-axis.

image

Hello @quicksightuser908908 and @ErikG !

@quicksightuser908908 Were you able to find a solution for this or was @ErikG’s suggestion helpful?

I would also recommend maybe changing how you name that value. So instead of “less than 1 year” try “1 year or Less”. I know that means changing up how you are measuring the data but it should allow for the correct sort.

You could create a “sort field”
ifelse({test_sort_by_tenure}="Less than 1 year",1,{test_sort_by_tenure}="1-2 years",2,.....)
Use the field with “avg” aggregation as sort option.

Hello @quicksightuser908908 !

Were you able to try @ErikG 's suggestion above, and if it worked could you mark their comment as a solution to help the community?

Hello @quicksightuser908908 !

It has been some time since we have heard from you but would still like to help you find a solution.

If we do not hear from you in the next 3 business days this topic will be archived.