# How to order chart legend based on pivoted field

**URL:** <https://community.omni.co/t/how-to-order-chart-legend-based-on-pivoted-field/413>\
**Category:** Visualizations\
**Created:** [November 4, 2025, 10:40pm UTC](https://community.omni.co/t/how-to-order-chart-legend-based-on-pivoted-field/413 "2025-11-04T22:40:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![James](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@James](https://community.omni.co/u/James)\
**Post date:** [November 4, 2025, 10:40pm UTC](https://community.omni.co/t/how-to-order-chart-legend-based-on-pivoted-field/413/1 "2025-11-04T22:40:45Z")

</div>

When building a chart that’s colored by a pivoted dimension, you may see the legend sort order not match the pivoted field sort order.

 ![Screenshot 2025-11-04 at 14.36.26](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/bc5cce422787540831bd44d8fbaf711130716ecb.png)

To resolve this, you’ll want to `fill in missing cells in grid` to convert the null values to zeroes. [Querying data | Omni Analytics Documentation](https://docs.omni.co/docs/querying-and-sql/querying#pivoted-table-filling)

 ![Screenshot 2025-11-04 at 14.38.55](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/7d54493175964a8a5669ceb2498f4d9dfc88db37.png)

And then the chart legend order will match the pivoted field.

 ![Screenshot 2025-11-04 at 14.40.18](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/f1b88a92724715195f81fd010cc167b1771d6da5.png)
