Custom Sorting in SAQL, Domo, and BI Dashboards Without Ugly Number Prefixes

Sorting in Salesforce CRM Analytics (CRMA) should be simple—but if you’ve ever tried to create a custom sort order in SAQL, you’ve probably hit a frustrating limitation. Since text fields default to alphabetical sorting, categories like High, Medium, and Low often appear in the wrong order:
What you want (logical sort) | What you get (alphabetical sort) |
---|---|
Low | High |
Medium | Low |
High | Medium |
Most BI tools, including CRMA, Domo, and Tableau, have the same issue. The usual fix? Prepending numbers (e.g., 1 - Low, 2 - Medium, 3 - High). But let’s be honest—that looks terrible in dashboards. It takes up visual space, and implies a numerical correlation that might not exist.

Fortunately, there’s a better way. By using invisible Unicode characters, you can control sorting without modifying the visible text. It’s the same idea as prepending numbers, but this uses characters that nobody can see instead of annoying numbers that everyone sees. This approach works directly in SAQL and applies to other BI platforms like Domo, Tableau, and Power BI.
Why Custom Sorting in CRMA (SAQL) Is a Challenge
- SAQL defaults to alphabetical sorting, making logical category orders difficult.
- Common sorting issues in CRMA dashboards (e.g., priority levels, status values).
- Other BI tools, like Domo and Tableau, have similar limitations.
Note that if your data is at the dataset level, you might have other options involving editing the XMD file. There’s a writeup here that looks promising, but I haven’t tried it because my issue was at the step level.
Common Workarounds
1. Prepending Numbers (1 - Low, 2 - Medium, etc)
✅ Ensures correct sorting
❌ Clutters dashboard labels
2. Creating a Separate Sort Column in the Dataset
✅ Works well for static datasets
❌ Doesn’t work for all visualizations
3. Manually Reordering in Dashboards
✅ Works if the tool allows it
❌ Not scalable for large or dynamic lists
The Unicode Trick: Sorting Without Visible Changes
When sorting text, characters are sorted lexicographically. This is a fancy way of saying alphabetically (mostly.)
Unicode is a text encoding standard. Back when computers started out, they generally supported the characters you’d find on a North American keyboard, and not much else. Of course, there are a lot of other alphabets out there, plus, well, 💩.
But for our purposes, there are a bunch of characters that exist that don’t actually show up on the screen. Here are a bunch of them:
Code | Character |
---|---|
U+200B | Zero Width Space |
U+200C | Zero Width Non-Joiner |
U+200D | Zero Width Joiner |
U+2060 | Word Joiner |
U+2062 | Invisible Times |
U+2063 | Invisible Separator |
U+2064 | Invisible Plus |
Most of these characters sort before the English alphabet, allowing us to influence the order without changing visible text. If we put those characters at the beginning of our strings, being mindful of their sort order, we can control the sort to be whatever we want.
Step-by-Step: Implementing the Unicode Sorting Trick in CRMA
Step 1: Identify Your Sort Order
Example: Low → Medium → High
Step 2: Modify Your SAQL Query
Insert invisible Unicode characters directly into the SAQL step. Note that many languages have a way to write out unicode strings in a format like \u20b0, but SAQL isn’t great at that, so you’re going to have to paste the character directly into the string, using a site like the one linked in the table above to help.
This means that you’re going to be effectively writing invisible code, and the next person to look at it (or you in a month) isn’t going to know what’s going on! Use comments liberally here.
To make this easier to see, I’m using different emojis in the example below, so… don’t just copy and paste this and wonder why it didn’t work. You’ll want to copy actual Unicode characters (200B, 200D, 200E) from Unicode Explorer and paste them into your SAQL.
q = foreach q generate
case
when Status == "Low" then "☝️Low" // U+200B (zero-width space, pasted manually)
when Status == "Medium" then "✌️Medium" // U+200D (zero-width joiner, pasted manually)
when Status == "High" then "👌High" // U+200E (left-to-right mark, pasted manually)
else Status
end as CustomSortStatus;
Step 3: Verify Sorting in CRMA Dashboards
- Preview the sorted SAQL step result.
- Ensure the labels appear unchanged but sort correctly.
Applying This Trick to Other BI Tools
This is going to vary depending on your platform and needs. In Domo, you can use beast mode calculations to prepend the characters, and Tableau and Power BI are probably best suited to calculated fields. But the concept is pretty straightforward everywhere.
Pitfalls and Best Practices
Is this a brilliant solution or a terrible hack? Probably both. But as with anything a bit out of the ordinary, there are a few things to watch out for.
Some tools might strip out invisible characters, and it’s really hard to see invisible things! So remember to test your dashboards often if you’re making changes.
Depending on the nature of the data, you could run into trouble with filters and searches. In my scenario, I was just trying to control the sort of a legend and bar segments, so there wasn’t much risk. Your mileage may vary!
I mentioned this earlier, but it bears repeating: you’re going to want to comment your code. If you don’t make it clear what you’ve done, it’ll seem like magic to the next person and they won’t be able to build upon it, and there’s a risk that someone will undo what you made without even realizing it.
Wrapping up
It’s pretty rare that I’ve found a BI solution that does exactly what I want out of the box without some level of tweaking, and this example is no exception. Overall, this is a pretty platform-agnostic approach that covers a range of bases, so it was worth writing up so the next time I Google around for an answer, I’ll end up right at home.