KNOWLEDGE BASE

## How to Align Text Displayed in a Dual Axis Measure Column

Published: 15 Dec 2023

### Question

Text is center-aligned in a dual axis measure column. For numerical values, how can we right-align the text?
Note: Dual axis measure column is used when conditionally formatting cell background color as in Example 2 of this article, for example.

### Environment

• Tableau Desktop

When placing text in a dual axis measure column, the text is centered on the axis zero line as follows.

If the numeric values need to be right-aligned, it is possible to make them appear right-aligned by adding a blank spaces to the text prefix and adjusting the axis range.

Follow along in the sample packaged workbook found in the Attachments section to right-align text displayed in a dual axis measure column. In our example, the following data is used.

1. Create a calculated field and name it Container.
`0`
2. Create a calculated field and name it Sales (length-adjusted).
Note: To unify the length of numerical text, blank spaces are added to the text prefix using the SPACE function. Minor adjustments are necessary depending on your actual length of the numerical text.
```IF LEN(STR(SUM([Sales]))) = 1 THEN
RIGHT(SPACE(10)+STR(SUM([Sales])),10)
ELSEIF LEN(STR(SUM([Sales]))) = 2 THEN
RIGHT(SPACE(10)+STR(SUM([Sales])),8)
ELSEIF LEN(STR(SUM([Sales]))) = 3 THEN
RIGHT(SPACE(10)+STR(SUM([Sales])),6)
ELSE
STR(SUM([Sales]))
END```
3. Add ID and Product to Rows.
4. Add two SUM(Container) to Columns.
5. Right-click the second SUM(Container) in Columns and select Dual Axis.
6. Click the left SUM(Sales) in Columns. Then, SUM(Container) marks card will be opened.
7. Change the marks type to Text.
9. Click the right SUM(Sales) in Columns. Then, SUM(Container)(2) marks card will be opened.
10. Change the marks type to Square.
11. Add a field used to determine the color of the cells to Color. In our example, add SUM(Sales) to Color.
Note: Adjust the width of the view, the size of Square, the color opacity, etc, as you need.
12. Right-click the top header and select Edit Axis. Configure it as follows.

13. Right-click the bottom header and select Edit Axis. Configure it as follows.
Note: Adjust the axis range to make the text appear right-aligned.

14. Right-click the top header and select Format. Change the Borders and the Lines format as follows.