How can you customize sort order in a category selector? For example, I want to sort a category field with categories: "yes", "no", and "unknown", but I don't want them in alphabetical order (ascending or descending). What do I do?
Hi Celeste,
I don't understand the question.
Do you have another example?
-Bill
Sure Bill,
Maybe it would help if I inserted a photo example:
I want the options to be in the following order: Yes, No, Unknown
But the only options are No, Unknown, Yes OR Yes, Unknown, No (because you can only sort Ascending or Descending. I run into this with several other category selectors, too. Age ranges, for example, are text variables and not numeric, so an age range 5-9 would be sorted "higher" than 15-19 because of the 1 in 15.
Okay,
You could add a field to your table to sort on.
Or,
If you have a feature class with lots of repeated values in the category field >
It is tempting to join it first but esri does Not currently support this when you publish it with Feature Access enabled.
(Map Service join is supported but then the ability to select a chart and have the map interaction is not supported - Only works with Feature Access enabled. "Catch-22")
So you can use the new table to present the sorted selector and have its filter options control selection of the other widgets.
-Bill
Currently the custom sort is not supported to arrange the Selector buttons on the Dashboard. The only option is to sort Ascending/Descending based on an attribute fields.
To workaround this limitation, you may create a new column and assign the numbers (according to the desired arrangement). Then, create a list for this column and use category names for labels and sort numbers (values from the field) as codes. Then use this column as the category field in Selector on the Dashboard. While sorting is based on the numeric values, categories show up with their labels.
Best,
MJ
HI MJ,
I just followed these directions to be able to sort based on day of week. I set up a new field, added a domain list and labeled it Monday through Sunday. Then I added the codes 1-7. When creating a serial chart in operations dashboard, I select this field in category and sort based on name. The chart is still sorted by the label and not the code. Did I miss a step?
Hi Samir Farhat,
Without checking your data table and the domain list you created I cannot be sure if you have missed a step or not. However, I'm able to confirm that this workaround still works. Images below show the details of my data and configuration:
Please check your table and domain list and let me know if it's still not working for you so we can take a closer look.
All the best,
MJ
I think I see my error. The field Daywithdomain contains the label on my table, not the code. Is there a way to quickly calculate that field to convert the label to its corresponding code?
You can open your hosted feature layer in Pro, use Select by Attribute to select all records for each day, then use Field Calculator to replace them with their respective codes.
Alternatively, you can use an Arcade expression with some conditional statements to populate values in a field based on the existing values in another field. In order to use Arcade, make sure that sync is not enabled for your layer. You can use an Arcade expression like below.
If you need more details about this workflow, see this link How To: Populate a new field with values based on substring values from another field using Arcade e... .
if (Find("Monday", $feature.Day, 0)>0) { return "1"; } else if (Find("Tuesday", $feature.Day, 0)>0) { return "2"; } else if(Find("Wednesday", $feature.Day, 0)>0) { return "3"; } else if(Find("Thursday", $feature.Day, 0)>0) { return "4"; } else if(Find("Friday", $feature.Day, 0)>0) { return "5"; } else if(Find("Saturday", $feature.Day, 0)>0) { return "6"; } else if(Find("Sunday", $feature.Day, 0)>0) { return "7" }
Best,
MJ
Ok. It looks like that expression will work, however, If you see the images below, the day_num field will not accept a number.