Exclude current week in Tableau automatically - tableau-api

I have set of data that is automatically updated each day with new lines.
On the other hand my graphs shows weekly/monthly data.
Is there any way to exclude current week/month, so that the graph can be automatically updated on the server, without me manually excluding and including weeks/months each time I have data for full week/month?

Here's another option which I use regularly in my reports.
Index your date field by week, with a calculated field:
STR(DATEDIFF('week', [Date], today(), 'monday'))
Note that here I have specified my weeks start on Monday, your requirement may be different.
Drag this field onto filters and exclude the value 0, as in the index the current week will always be 0, last week will be 1 etc.

This is an untested example of a calculated field to exclude current week:
IF DATETRUNC('week',[your date field]) = DATETRUNC('week',NOW()) THEN
'filter me'
ELSE
'leave me'
END
Drag that calculated field to filters. In case you couldn't guess, exclude the 'filter me' value :)

make a copy of your date field. Drop on filter, select condition tab, select by formula and drop this in the field:
datetrunc('week',[Order Date (copy)]) <> datetrunc('week',today())

Related

Power Query - Subtract the earliest date in one column from the record-specific date in another column

Every month I download a set of data into a report. That data consists of multiple records and each record has a record specific date as well as having the month end report date on the record's data-row.
I have used Power Query to upload all of these month end reports. I want use Power Query to be able to compare the column of record dates with the earliest date in the column of report dates to see if anybody has fiddled any data entry. The query table has the following headings.
Record ID Record Date Report Date
I've tried adding a custom column using the formula = if Record Date < List.Min(Report Date) then "Old" else "New"
this didn't work and I've spent ages trying to get a solution. I've also tried using Groups to get the minimum value, but I lose all of the other columns, which I want to keep. Any help really appreciated.
You have to refer to the fields in [], so here [Report Date]
To pick a column use Source[Field], so here #"PriorStep"[Report Date]
The List.Min function is not pulling as a number so you cant use <
Insert a Number.From in front of the calculation to convert to number
Same need to add Number.From in front of [Record Date] pulling as a date
Combined code:
#"Added Custom" = Table.AddColumn(#"PriorStep", "Custom", each if Number.From([Record Date])<Number.From(List.Min(#"PriorStep"[Report Date])) then "Old" else "New")

How to selectively filter based on a dimension?

Link to tableau graph
I want to selectively filter the above graph based on the year. For example, when I deselect December, I want only the 2018 values to be excluded while keeping the December values for the other years.
Tableau version: 2018.3.0
You can create a calculated field called something like "year-month of order date" that contains logic such as YEAR(Order Date) * 100 + MONTH(Order Date). Drag that field to the filter box and include it on the dashboard. Then the user can exclude any combination of year and month combination.

Month filter to be defaulted to current month whenever user opens the report

I have a month column in the data and I am adding this as a filter so that user can filter whichever month he wants.
I want the month filter to be defaulted to current month whenever user opens the report and then he can change the month based on his needs. Is this possible in spotfire?
You can create the calculated column with the following definition and pick current month as a filter.
If(Month([Date])=Month(DateTimeNow()),"Current month",String([Date]))

Date filter for not showing the recent date data in Tableau

I am building a dashboard for retention. The data that I am getting for the most recent day seems to have huge spikes because the denominator is not having entire data for the day.
So, I just want to show the data till previous day and it should be automated likewise.
Please let me know if anyone had dealt with the same problem.
Thanks,
Sai
The best way to do this is through creating a calculated field:
Create a field called Recent Date as follows:
DATETRUNC('day',[Date]) = {FIXED : MAX(DATETRUNC('day',[Date]))}
What this does is creates a Boolean field where the most recent date will be flagged as TRUE and all others as FALSE.
Drag this field into the filters pane and select FALSE. This will remove the most recent dates data.
Create a calculated field to return a boolean value if the data is from today's date. Then filter on False.
DATETRUNC('day', [Your Date Field]) = DATETRUNC('day', TODAY())

Tableau Using Parameters for a Date Selector

I've been looking into making a date selector so instead of filtering by Month, Week by adding filters then displaying the quick filters to correspond. I want to be able to dynamically change the date so I can choose between Quarter, Month and Week in a single drop down.
I have made the selector part no problem it shows but when I come to my calculated field, it's not behaving how I would like.
Here is my calculated field:
CASE [Parameters].[Date Select]
WHEN 'Quarter' THEN QUARTER([Date])
WHEN 'Month' THEN MONTH([Date])
WHEN 'Week' THEN WEEK([Date])
END
This gives 2 errors...
Unknown Function QUARTER called
Unknown Function WEEK called
I am puzzled because the month one is fine.
Normally in tableau to get the month/quarter/week, I click on the Date dimension and select Month or week and it filters and displays like so: MONTH(Date).
Can anyone tell me where I'm going wrong and how I can pull the week and quarter from date in the calculated field so my selector will work.
Thanks.
There are no QUARTER and WEEK functions in Tableau, as you can see in the image below.
What you should be using to get these values are:
DATEPART('quarter',[Date])
DATEPART('week',[Date])
For filtering the date using your parameter as filter, I'll assume that you want to filter the current quarter, month or week. In this case you'll need to setup your paramaters like this:
Then you'll create a Calculated Field with the following formula:
DATEPART([Date Selector],[Date]) = DATEPART([Date Selector],TODAY())
This should give you a True/False dimension which you will use as filter for the value True. After that you should have a working parameter filtering your data accordingly to the value set.