Solution: Workaround For Custom X-Axis on Quicksight Line Charts

Hi there,

I’ve had this issue quite often, so I wanted to share a work-around that could save you a lot of time!

TLDR : To show a custom x-axis on a line chart, include a “reference line” with your desired x-axis values. Then hide this in your chart using a calculated field

So, many of you likely encountered an issue where you cannot set custom x-axis values or define a step-size for your x-axis.

I found a possible workaround for this. Here are the steps:

1- Create a “reference line” that contains the values you want to show on your x-axis.

Set the y-value of these rows to be something that you wouldn’t see in your data. For example, negative values.

Screenshot 2023-07-07 at 9.48.05 AM

If you’re using filters, make sure to include a combination of columns in the reference line values so that you’re x-axis doesn’t change when applying filters.

2- Use a calculated field on your Y-Axis to hide the “reference line” data

For example, in this case, I removed all values that were less than 0, since that was my reference line’s data was negative (and my data wasn’t)

Screenshot 2023-07-07 at 9.56.19 AM

3- Result!

Set the Y-axis equal to this new calculated field. Here’s what it’ll look like:

You might also want to show your y-axis as a “continuous line” rather than a broken one.

Note- your legend and tooltip will have a new line called Reference Line. I’d recommend calling this something that won’t be confused with real data, like “reference line” or “ignore this”

That’s it! I took me a while to find this solution, so hopefully it saves you a lot of time :slight_smile:

1 Like

Hello @olivercarmont ,

Thank you for sharing this!