Switch Axes in Excel: How to Swap Rows and Columns
In this article
To switch axes in an Excel chart, select the chart, go to the Chart Design tab, and click "Switch Row/Column." This instantly swaps the data plotted on the horizontal (X) axis with the data plotted in the legend (series), allowing you to change the perspective of your visualization without rewriting your data table.
Depending on your goal, "switching axes" can mean two different things: changing how a chart displays data or physically swapping the rows and columns of a data table (known as transposing). This guide covers both methods to ensure your data is presented exactly how you need it.
What You'll Need
- A computer with Microsoft Excel installed (Windows or macOS).
- An existing dataset or a chart already created from a data range.
Step-by-Step
Method 1: Switching Axes in a Chart
Use this method when your chart is already created, but Excel has plotted the categories on the wrong axis (e.g., the dates are in the legend instead of on the bottom axis).
- Click anywhere inside the chart area to activate the chart tools.
- Look at the top ribbon menu. Click on the Chart Design tab. (Note: Depending on your version of Excel, this may simply be labeled "Design").
- In the Data group, click the button labeled Switch Row/Column.
- Excel will immediately swap the X-axis labels with the legend series. If the button is greyed out, ensure your data range is a contiguous block of cells.
Method 2: Swapping Rows and Columns in a Spreadsheet (Transpose)
Use this method if you need to physically flip your data table so that rows become columns and columns become rows before you even create a chart.
- Highlight the range of cells containing the data you want to switch.
- Right-click the selected area and choose Copy (or press Ctrl+C on Windows / Cmd+C on Mac).
- Click on a blank cell where you want the new, flipped table to begin. Ensure there is enough empty space to accommodate the new dimensions of the table.
- Right-click the blank cell. Under Paste Options, look for the Transpose icon (a small clipboard with two rectangles forming an L-shape).
- Click the Transpose icon. Your data will now be flipped across the diagonal axis.
Method 3: Using the SELECT DATA Dialog (Advanced)
If "Switch Row/Column" does not produce the specific result you want, you can manually redefine the axes.
- Right-click the chart and select Select Data... from the context menu.
- In the Select Data Source dialog box, you will see two sides: "Legend Entries (Series)" on the left and "Horizontal (Category) Axis Labels" on the right.
- To change the X-axis, click Edit under the Horizontal Axis Labels section and select the range of cells you want to appear on the bottom of the chart.
- To change the series, click Edit or Add under the Legend Entries section to specify which data columns should be plotted as lines or bars.
- Click OK to apply the changes.
Common Mistakes
- Overwriting Data: When using the Transpose method, users often try to paste the flipped data directly over the original data. Excel will not allow this if the ranges overlap. Always paste into a fresh, empty area of the sheet.
- Including Empty Rows: Including blank rows or columns in your selection before clicking "Switch Row/Column" can confuse Excel, leading to gaps in the chart or the "Switch Row/Column" button being disabled.
- Confusing Transpose with Sorting: Transposing flips the orientation of the table; it does not reorder the data alphabetically or numerically. If your data is in the right place but the wrong order, use the "Sort & Filter" tool instead.
Tips
- Dynamic Transposing: If you want the flipped data to update automatically when the original data changes, use the
=TRANSPOSE(array)formula. Select the destination range, type the formula, and press Ctrl+Shift+Enter (for older Excel versions) or simply Enter (for Microsoft 365). - Check Your Headers: Ensure your data has clear headers in the top row and left column. Excel uses these headers to determine what belongs on the axis and what belongs in the legend.
- Use Tables: Convert your data range into an official Excel Table (Ctrl+T) before creating a chart. This makes switching axes and adding new data much smoother.
Troubleshooting
The "Switch Row/Column" button is greyed out
This usually happens if the chart type does not support switching axes (such as some specialized Map or Treemap charts) or if the data source is not a simple range. Try selecting the data again or using the "Select Data" dialog to manually assign the axes.
The chart looks messy after switching
When you switch axes, the scale of the chart may change. If your bars are now too thin or your lines are overlapping, right-click the axis and select Format Axis. Here you can adjust the minimum/maximum bounds or change the axis type from "Date axis" to "Text axis."
Transpose didn't copy the formatting
The Transpose paste option primarily moves the values and basic formatting. If you have complex conditional formatting or data validation, these may not carry over perfectly. You may need to re-apply specific cell colors or borders to the new layout.
Frequently Asked Questions
Can I switch axes on a Pivot Chart?
Yes, but you do not use the "Switch Row/Column" button. Instead, go to the PivotChart Fields pane and drag the fields between the "Axis (Categories)" area and the "Legend (Series)" area.
Does transposing data change the formulas?
If you use Copy > Paste Transpose, Excel attempts to adjust cell references, but complex formulas may break. If you use the =TRANSPOSE() function, the formulas remain linked to the original source cells.
Is there a keyboard shortcut to switch axes in a chart?
There is no single default keyboard shortcut for "Switch Row/Column," but you can use Alt shortcuts: press Alt, then JG, then W (this sequence may vary slightly by Excel version).
Why did my dates move to the legend?
Excel often guesses which data is the "label" and which is the "value." If your dates are in a column that Excel perceives as a data series, it puts them in the legend. Clicking "Switch Row/Column" fixes this instantly.
Can I switch axes on a Scatter Plot?
Scatter plots are different because both axes are numerical. You cannot use "Switch Row/Column" to swap X and Y. Instead, right-click the chart, go to Select Data, edit the series, and manually swap the cell ranges for the X and Y values.