Tableau: Conditional Formatting Rows based on a data range - tableau-api

Any help you can provide would be appreciated. I can't find any tableau tutorials that deal with conditional formatting based on dates. Plenty of formatting based on cell values, but that doesn't help in this case.
I am trying to create a tableau report that shows the change records that are due within the below criteria and color code the rows accordingly.
The next seven days represented by "red"
The next 14 days represented by "yellow"
Greater than 14 days out represented by "green"
Everything else would have a white background

Something I did that sounds similar was around due dates:
Create a calculated field called "Due Date Traffic Lights" to work out your days amount. The below gives the date difference between the given date field and today:
DATEDIFF('day',MAX([Due Date]), MAX(TODAY()))
Create calculated field "if" function called "Due Date Range" to categrorise these results:
if [Due Date Traffic Lights] < -7 THEN "GREEN: Over One Week Left"
ELSEIF [Due Date Traffic Lights] > -7 AND [Due Date Traffic Lights] <0
THEN "ORANGE: Due in one Week"
ELSE "RED: Overdue"
END
So on your rows you can then drag the "Due Date Range" into your "Color Icon" and set the color for each of the 3.

Related

how to get number of days from relative dates filter?

I want to get number of months user selected using Relative Dates Filter?
If user entered "Last 3 Months" then I wants to get number of days for 3 months to use these days in another calculated field.
Calculated field which is using this is as follows.
([Total Sale within Entered Date]/[Number of Days])*365
which returns me predicted sales for the whole year.
Here, [Number of Days] is the filter which I am using. Picture added for Relative Dates filter I am using.
Screenshot of Relative Date Filter:
You need to create a calculated field that works out the number of days in the data.
Something like datediff('day',min([dates]),max([dates])) if data is present for all the days in the time period will work. This calculation will dynamically give you the number of days between the first and last date in the [dates] field for whatever data is selected by the filter (so won't be precise if not all the possible dates are represented in the dataset).

tableau to show both last and previous 12 month

In one worksheet, to display the measure value (Sales) of Last 12 Months(LTM) and Previous 12 Months(PTM) from the selected month.
Current Month is 2018-June , By default selection
PTM date range for the sales period as (2016-June to 2017-May)
LTM date range for the sales period as (2017-June to 2018-May)
If user selects different month from the drop down, let's select (Apr 2018)
PTM date range as (2016-Apr to 2017-Mar)
LTM date range as (2017-Apr to 2018-Mar)
This can be done using a parameter. Here are the steps involved:
Create a date parameter
Create a calculated field as below(You might need to fine tune it to match your exact requirements)
Add the calculated field to filter card to show only 'SHOW'

Change date from calander date to date since first record in tableau

So, pretend I'm looking at sales of an item vs time. One item I started selling 3 years ago and one is from only a year ago.
I want to look at how the performance of both items change starting from first date sold as "day 0" not from first date sold as say "march 2016".
My date field is a calendar date and I'm not sure the best way line everything up from within tableau that will allow me to display the result on a single graph. I'd also like an option that will scale to 10+ items
Any approaches would be great!
Create a calculated field called first_Sale_date_per_item defined as {fixed Item : min(sale_date)}
Then you can define days_since_first_sale as datediff('day', first_sale_date_per_item, sale_date)

SSRS background color expression based by date value

Here is my issue, I have a table in SSRS that I've created that has a due date field (RegulatoryDateDecisionDue). Based on that date field, I need to change the colors of the rows if today's date is past the due date the field should be red. If the amount of hours are less than or equal to 72 hours from today's date till the due date (basically like a countdown till it's due), the rows should be orange, else rows should be white.
Here is the expression I wrote, but I am having an issue, I get error, and idea what I am doing wrong or if I should be doing this differently? Any and all help appreciated.
=IIF((now() > Fields!RegulatoryDateDecisionDue.Value), "Red", IIF(((DateDiff(DateInterval.Hour, Fields!RegulatoryDateDecisionDue.Value, Now()) <= "72"), "Orange", "White")))
Try:
=Switch(
DateDiff(DateInterval.Hour, Fields!RegulatoryDateDecisionDue.Value, Now())<=72,"Orange",
Fields!RegulatoryDateDecisionDue.Value<now(),"Red",
true,"White"
)
It is better use Switch for multiple conditions.
Let me know if this helps.
Some things to try :
Use a switch instead of iif to have a better reading
use "h" insted of DateInterval.Hour
write 72 instead of "72"

Error using [Today] in Sharepoint filter

I'm having issues creating a filtered view in a SharePoint list. The filter should display any results with a Created date from "this week". In my case, "this week" is from the previous Saturday through the upcoming Friday.
I get the error message "Filter value is not in a supported date format." when trying to create the filtered view.
Here are my filters:
Show the items when column
Created
Is Greater than or Equal to
[Today]-WEEKDAY([Today])
and when column
Created
Is Less than or Equal to
[Today]-WEEKDAY([Today])+6
What am I missing? And is it as simple as I'm guessing it probably is?
You can't use complex formula in Filters - you have to keep it simple like [Today]-30 for last 30 days.
The solution is to turn the problem on its head and add calculated columns to work out the start of the week and the end of the week then filter when the current date is between those dates (i.e. Start <= [Today] AND End >= [Today])
This post gives you more details - its based on the Current Calendar Month but the same technique can be sued for calendar week - see formula at bottom.
http://blog.pentalogic.net/2009/11/howto-filter-items-current-calendar-month-view-sharepoint/