4 Replies Latest reply on Apr 7, 2016 12:20 PM by Oscar Castro III

# Creating a Bar Chart But Need Different Days to Change Colors

Good morning,

I am fairly new to Tableau and wanted to know if it is possible to change specific days to different colors on the bar chart below.  Reason being is that I'm taking an average of the the past four Tuesdays so I would like all the Tuesdays in the bar chart to be a different color.  This will be a rolling 30+ days so it would need to be dynamic.  Any help will be greatly appreciated.

-Oscar

• ###### 1. Re: Creating a Bar Chart But Need Different Days to Change Colors

hi Oscar,

So yes we can do this...

If you create the following calculated field

DATEPART('weekday',[Order Date]) = 3

and then drag that onto your colour-tile, you'll have a different colour for all the Tuesdays.

Hope that makes sense, but please post back if not.

• ###### 2. Re: Creating a Bar Chart But Need Different Days to Change Colors

Oh wow, very cool.  Thank you so much, it worked.  Last question, will this be dynamic?  So going forward the bars will move from Tuesday to Wednesday, etc.?

-Oscar Castro III

• ###### 3. Re: Creating a Bar Chart But Need Different Days to Change Colors

So it depends what you mean by dynamic! the DATEPART('weekday',...) function returns the day of the week, as integers (Sunday = 1, Monday = 2...) so this formula will always highlight Tuesdays, as the check is just if the DATEPART('weekday',...) =3.

If it was that the last day of your data is a Tuesday, and that's why you wanted that picked up...and so tomorrow the last day of the data will be Wednesday, and so you'd want all Wednesday's highlighted? we need to make an amendment to the formula...although this brings in a calculation type called LoDs (If you are not familiar with these there are some great resources...First would be to watch the On-demand training video on them [I think there are 2], and also the 3 links below provide a great introduction to them

Understanding Level of Detail (LOD) Expressions | Tableau Software

I'm going to do the formula in 2 parts, for explanatory purposes, but you can nest into 1 (if you want) for your final solution.

So first we need to determine the weekday of the last day of your data

[Weekday - Last Day of Data]

DATEPART('weekday',{FIXED: MAX([Order Date])})

and then we can use this to highlight that day in your Viz, so our highlight day becomes

DATEPART('weekday',[Order Date]) = [Weekday - Last Day of Data]

There are other ways to go about this (we could have used a Table Calculation to pick up the last day of data, and thus it's weekday).

Hope that helps, and (with a bit of video-watching/reading) makes sense!

1 of 1 people found this helpful
• ###### 4. Re: Creating a Bar Chart But Need Different Days to Change Colors

Thank you so much Simon!  This helped a lot and worked .  You might see me more on this forum.  Once again, thank you.

-Oscar