Overview
Problem
You can use the Alignment function in Cell Attribute to set the alignment for entire rows or columns of cells uniformly, as shown in the following figure.
But how can you set different alignments for cells in a certain row (or column) under specific conditions?
For example, you can set Horizontal Alignment to Left for cells containing California and set Horizontal Alignment to Right for cells containing New York, as shown in the following figure.
Solution
You can add a New Value condition attribute with New Value set to an HTML formula and set Display Content to Display by HTML.
Alignment | New Value Formula |
---|---|
Left | CONCATENATE("<div>"+$$$+"</div>") |
Center | CONCATENATE("<div>"+$$$+"</div>") |
Right | CONCATENATE("<div>"+$$$+"</div>") |
Example
Data Preparation
Create a general report, and create a database query ds1 with the SQL statement SELECT * FROM Sales_Volume.
Template Designing
Drag the dataset fields into the corresponding cells, center the content, and set Data Setting to List for cell A2. Design the table style, as shown in the following figure.
Condition Attribute Setting
1. Select cell A2, add two condition attributes, and rename the attributes Left Alignment for California and Right Alignment for New York respectively.
2. Left Alignment for California: Set New Value to the formula CONCATENATE("<div>"+$$$+"</div>") when the cell value is California.
The formula CONCATENATE() is used to combine multiple strings into one single string.
3. Set Right Alignment for New York similarly. Set New Value to the formula CONCATENATE("<div>"+$$$+"</div>").
Cell Display Content Setting
Select cell A2, and choose Cell Attribute > Others, and set Display Content to Display by HTML, as shown in the following figure.
Effect Display
PC
Save the template and click Pagination Preview. The effect is the same as that shown in section "Problem."
Mobile Terminal
The report can be previewed on both the DataAnalyst app and the HTML5 terminal. The following figure shows the effect.
Template Download
For details, you can download the template Cell Alighment by Condition Attribute.cpt.