Last Modified Date: 01 Nov 2016
Option 1Use INDEX() to assign colors, and create a separate worksheet to use as a legend. See attached workbook for an example.
- Right-click your date field and select Create > Custom Date
- Enter the following, then click OK:
Name: Date at Day Level
- Place "Date at Day Level" on Detail.
- Select Analysis > Create Calculated Field
- Name the field "Index". Enter the following calculation, then click OK:
- Place "Index" on Color.
- Right-click "Index" on the Marks card.
- Select Compute Using > Date at Day Level, then click OK.
Option 2If the different lines we want to color will be a consistent number of days from today, a Calculated Field using the DATEDIFF() function can be used to assign colors:
- Create a Calculated Field called "DateDiff_today = " using the following formula:
DATEDIFF('day',TODAY(), [Date periods filtered] )
- Create a Calculated Field called "Datediff_with strings" using the following formula:
IF [DateDiff_today] = 0 THEN 'TODAY' ELSEIF [DateDiff_today] = -1 THEN 'YESTERDAY' ELSEIF [DateDiff_today] = -7 THEN 'LAST WEEK' END
- Drag the "Datediff_with strings" field to the Color Section of the Marks card.
CauseWhen a date result is used to color marks on a view, the colors are assigned for the resultant date, so the color for dates returned from a Calculated Field that uses the TODAY() function will change each day.
Additional InformationIf there is missing data in the data set, use the formatting options for the Value, under the Pane tab, for Special Values (eg. Null) and Select for Marks: Hide (Connect Lines) to eliminate any gaps in the data and retain the color encoding.
By using INDEX() to color marks, you can assign colors for days such as:
- 1 week ago
Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Training and Tutorials