KNOWLEDGE BASE

## Color Line Segments in an Origin-Destination Map by Point Order

Published: 07 May 2018
Last Modified Date: 08 Jan 2019

### Question

How to color line segments in an origin-destination map by point order.

For example, for a given path, you are attempting to make the first line segment of every path in the view red, the second segment blue, the third segment orange.

Tableau Desktop

### Answer

1. Create the following calculation, called [Segment Even Numbers]:
`FLOOR([Point Order] / 2) * 2`
2. Create another calculation, called [Segment Odd Numbers]:
`FLOOR(([Point Order] - 1) / 2) * 2 - 1`
3. Add a second copy of the latitude or longitude field to the view, and make it Dual Axis.
4. Then, drag the [Segment Even Numbers] field to the Color shelf on one of the Marks cards.
5. Drag [Segment Odd Numbers] to the Color shelf on the other Marks card.
Note: Open the sample workbook Color Segments by Step.twbx to see the final View.

### Additional Information

• Tableau displays information with marks.
• It is the points and not the line segments that determine the marks in the view.
• Therefore, a point can only be used to display a single line segment, even though it connects with two line segments--unless Dual Axis is used.
• For more information about the FLOOR function, see Number Functions in Tableau Help.

Discuss this article...
Did this article resolve the issue?