How to create default date set on a calendar in Tableau - tableau-api

I have one vertica query in my tableau,
select * from mytable where Date(sometimestamp) between
start_date and end_date
As you can see data varies as per change in date range.
My issue is to set start_date as default to current_date - 90 and end_date as current_date.
There is not issue in making end_date as current_date but no idea about how to set start_date as current_date-90 in tableau.
I tried making calculated fields etc but none helps.
Could you please guide me on how to do that.
Note - Both, start_date and end_date should be calendar component not dropdowns or slider.

You can accomplish this by adding a filter to your data source -- note that you won't be able to control this filter from the dashboard (if that's what you want to do, you'll need to create a calculated field and let the users interact with it), rather, this is a datasource level filter.
Go to the data source and click "Add" under the filters text in the top right, then click "Add"
Click the "Relative dates"
Then, select Relative Dates, Months, Last 3 (Or select Days and enter 90 under the "Last" radio button) and press OK.
You said you have the end date handled, but you can create another data source filter to handle the end date if you want.

Related

PowerBI, DAX. Is there a way to set an upper limit to a slicer?

I'm trying to create some measures using DAX on an underlying data model which I would then use for creating some visuals (line chart, bar chart etc.). Each table in the data model has a data field (date&time) that contains repeated dates and times (more occurencies with the same date&time). To use the metrics in the visuals I need the measures to be grouped for date (only date, not for time).
To achieve the task I've created a calendar table (using CALENDAR in DAX) to set-up a set of dates (only dates) to which refer at for every table in the data model and created relations (dates that points to calendar date) for every table. I set the upper limit of the calendar table to be a year ahead of the max date in the dataset, because some measures need to be evaluated in the future.
In the visual pages, I put a slicer that points to the calendar table dates, but the date interval is too wide. I need the slicer to have a more narrow interval, let's say, only "for the present and the past" but I prefer not to add another calculated table.
In your opinion, is there a way to limit the slicer without changing its reference to the calendar table?
Thanks!
For the calendar you may just use CALENDARAUTO(). It will expand automatically as the data model expands.
For the slicer, just select it, open the filter pane and define a filter with the upper limit you want.
You can use combination of 3 different slicer for your purpose. This is just another option that you can have a look on. There will be 3 slicer for Year, Month & Date. So Date slicer is you final slicer, with 2 other slicer on top of it to generate necessary Dates in the slicer. This way, you are not making any static restriction to generate the Date list but giving the user full control on the Date range. Here below is a sample how the slicers can be look in practical.
User can select any year or multiple year, any month or multiple month. Finally the date slicer will hold Date values accordingly.

Exclude current week in Tableau automatically

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())

Tableau (Data > X days)

I'm a novice to Tableau, not going to lie. But for the life of me I can't figure out how to pull data from a table that's greater than thirty days old.
Basically, I have a set of work orders, and I'm just trying to get the count of the total work orders that are open AND older than thirty days. How would I go about doing this? I feel like it's a lot simpler than I'm trying to make it out to be.
You will have to create a calculated field and filter on that.
right click on your date field choose Create/Calculated Field
Use this formula, with [Date] being your date field: TODAY() - [Date] or, more flexible DATEDIFF("day" , [Date], TODAY())
give it a name eg. datediff
drag and drop datediff to the filter shelf, choose "all values" and set the range, for you 0-30
That should do the trick.
You can use your date filed as a filter and choosing the relative filter format.

Qlikview button make selection

I have a button that when it is clicked I want it to select the last 14 days. This means that if today's date is 2014-03-12, I want it to select all dates between 2013-02-26 and 2014-03-12.
I have a time_table with the fields KEY_timestamp (yyyy-mm-dd), year, month, day.
In my button I have an action Select in Field, with the field KEY_timestamp and I have a Search String which looks like
=if(
now() - 14 < KEY_timestamp,
KEY_timestamp
)
Now, to tell you the truth I have no idea how to go about this, and my experience with Qlikview is limited at best... I hope somebody can point me in the right direction. I tried Googling this but I've been unsuccessful so far.
In the search string type only this line:
='>' & date(now()-14) & '<= ' & date(now())
If it didn't work properly, add this line in your script:
date(KEY_timestamp) as KEY_timestamp_formatted
and then replace your select in field with the new column

SQL Services Reporting Services Cascading Parameter

I have 2 parameters in my report to select a date range:
StartDate & EndDate
I want to hide the StartDate and allow users to just select the EndDate which should then dynamically change the start date to 1 year before the EndDate.
I need this to happen every time a user changes the EndDate changes.
I'm pretty sure I have to use cascading parameters, but I don't know how.
Any suggestions?
Yes, cascading parameters are the trick if you want to do this at the report level. (You could also handle this pretty effectively at the query level.)
First arrange the parameters in your report in order of dependence: EndDate should be be listed above StartDate. Use the up and down arrows to rearrange the parameters.
Set the StartDate parameter to be "Internal" and set the default value appropriately. Select "Specify values" and create a value of =DATEADD( DateInterval.Year, -1, Parameters!EndDate.Value )
Now you can use both #EndDate and #StartDate in your query without initializing them and they will be passed the SSRS value.