# Sort Charts with an X axis by a Measure Value instead of Dimension

**URL:** <https://community.omni.co/t/sort-charts-with-an-x-axis-by-a-measure-value-instead-of-dimension/208>\
**Category:** Visualizations\
**Tags:** content\
**Created:** [January 7, 2025, 5:22am UTC](https://community.omni.co/t/sort-charts-with-an-x-axis-by-a-measure-value-instead-of-dimension/208 "2025-01-07T05:22:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jiro](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.omni.co/jiro/32/268_2.png) [@Jiro](https://community.omni.co/u/Jiro)\
**Post date:** [January 7, 2025, 5:22am UTC](https://community.omni.co/t/sort-charts-with-an-x-axis-by-a-measure-value-instead-of-dimension/208/1 "2025-01-07T05:22:42Z")

</div>

Whenever you have a viz with an X axis, the sort of that axis will always be based on the **x axis dimension** regardless of how the results are ordered by a measure. However, in some cases you may want to sort the results by a measure like your Top 5 Brands by Inventory Sold.

In those scenarios, there is a quick workaround to achieve the desired sorting order as long as you’re sorting \< 10 values (see limitations).

## Workaround: Concat the row number with the x axis string

1. Insert a new column
2. Combine the row number function with your desired X-axis field
3. Use this new concatenated field as your X-axis.
4. Sort by your desired measure.

## Example Implementation

Let’s say you want to look at your Top 5 brands by inventory sold and show some revenue information like Margin and Total sales. In this case a scatter chart is one solution where you sort by Inventory Volume, size by total sales, and color by Margin.

1. Sort the results by Total Order Items
2. Create a new field called “Top Brands” with formula =`CONCAT(TEXT(ROW(),"00), '. ', A1)` (Note: if you are sorting less than 10 rows you can skip the TEXT() function)
3. Set Top Brands (rather than Brands) as your X-axis in the chart options
4. Drag Total Sales to the size section
5. Drag Total Margin to the color section

The result will show numbered countries on the X-axis, sorted by your chosen measure:

 ![Screenshot 2025-01-06 at 10.01.20 PM](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/5312e6bafd6569afbadc0424f2eaa5d35d0d665b.png)

---

<div class="post-metadata">

**Author:** ![colin](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.omni.co/colin/32/112_2.png) [@colin](https://community.omni.co/u/colin)\
**Post date:** [January 7, 2025, 5:28am UTC](https://community.omni.co/t/sort-charts-with-an-x-axis-by-a-measure-value-instead-of-dimension/208/2 "2025-01-07T05:28:59Z")

</div>

Can work around the string sort using TEXT() with leading 0s, so TEXT(ROW(), “00”) would fill to two digits.

---

<div class="post-metadata">

**Author:** ![Jiro](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.omni.co/jiro/32/268_2.png) [@Jiro](https://community.omni.co/u/Jiro)\
**Post date:** [January 7, 2025, 6:03am UTC](https://community.omni.co/t/sort-charts-with-an-x-axis-by-a-measure-value-instead-of-dimension/208/3 "2025-01-07T06:03:44Z")

</div>

Ah thanks Colin, updated the post!
