How to Apply Custom Sorting in Bold BI Using Expression Columns
Published:
In Bold BI, you can use an expression column to apply a custom sorting order in a chart when the required order does not come directly from the original field values.
- This approach is useful when you want to sort categories based on business logic such as:
- High, Medium, Low
- Critical, Warning, Normal
- VIP, Preferred, Standard
- Instead of relying on alphabetical order, create an expression column that assigns a numeric rank to each category and then use that expression as the sorting field in the widget.
Steps to apply custom sorting using an expression column
Step 1: Open the data design view
- Open the data source used by the dashboard and navigate to the data design view.
- In the data design view, click on the Expression icon in the toolbar.
Step 2: Add a new expression column
- In the Query Expressions window, click Add.
- Enter a name for the expression column.
Step 3: Define the custom sorting logic
- In the expression editor, define logic to assign a numeric rank to each category (lower number = higher priority).
- Ensure the expression evaluates correctly without errors before saving.
Example expression:
CASE
WHEN [Priority] = 'Critical' THEN 1
WHEN [Priority] = 'High' THEN 2
WHEN [Priority] = 'Medium' THEN 3
WHEN [Priority] = 'Low' THEN 4
END
This expression assigns:
Critical = 1
High = 2
Medium = 3
Low = 4
Ensure all possible values are handled to avoid NULL sorting issues. You can modify the logic based on your own sorting requirement.
Step 4: Save the expression and close the Expression Designer window.
- Click Save in the Expression Designer, then close the window and return to the dashboard.
- The saved expression will appear in the field list once the data source is saved and refreshed under:
- Measure Columns for numeric expressions
- Dimension Columns for string or date expressions
Step 5: Add the required fields to the chart
- Open the chart widget and add the original category field to the chart.
- Verify that the expression column appears in the field list. You do not need to drag it into the chart yet.
Step 6: Use the expression column in sorting
- Open the Sort settings for the category (dimension) field in the chart (usually via field options or settings panel).
- Inside the Sort dialog, set:
- Sort by → Field
- Field → PriorityOrder (the created expression column)
- Order → Ascending
- Click on the Apply button to save the changes.
Step 7: Preview the result
- Click Preview to verify that categories follow the expected custom order. If the order is incorrect, revisit the expression logic.
- The chart categories will now appear in the custom order defined by the expression column.
- If sorting does not apply, ensure:
- The expression returns numeric values
- No NULL values exist
- Correct field is selected in Sort settings
Key Notes
- Advanced Sorting (Sort → Field) is the recommended approach in Bold BI for sorting chart categories based on values or reference fields, rather than default alphabetical order.
- Expression columns are optional and are required only when implementing custom sort logic, such as enforcing a business‑specific category order.
- Dimension fields represent categorical data used as chart categories, such as:
- Country
- Product
- Customer
- Priority
- Measure fields represent numeric or aggregated data used for analysis, such as:
- Sales
- Quantity
- Profit
- Expression columns that return numeric values are treated as measure fields and can be used as sorting reference fields.
Conclusion
Using an expression column with advanced sorting enables you to enforce custom business logic ordering in Bold BI charts beyond default alphabetical sorting. This approach ensures your visualizations reflect meaningful category priorities while remaining flexible and scalable.