Filter multiple views with different dates on one parameter issue - tableau-api

I have two metrics: rep_id, user_id
I have three dimensions: rep_onboard_date, user_application_date, user_enrollment_date
I created a parameter called "Launch Date", which is a date that equals 1/1/2018. Note that I have data going back a few years before that.
I have three views:
1) columns = month(rep_onboard_date), rows=cntd(rep_id)
2) columns = month(user_application_date), rows=cntd(user_id)
3) columns = month(user_enrollment_date), rows=cntd(user_id)
I would like to create a single filter on the dashboard- to filter all, pre "Launch Date" and post "Launch Date".
I tried creating three calculated fields according to http://kb.tableau.com/articles/howto/creating-a-filter-for-start-and-end-dates-parameters so I created:
Onboard_Date = [rep_onboard_date]>=[Launch Date]
Application_Date = [user_application_date]>=[Launch Date]
Enrollment_Date = [user_enrollment_date]>=[Launch Date]
But then I can only add one or the other (or both) as filter- which isn't what I am looking for.
Note that adding these into one filter with an "or" statement doesn't work because when setting filter=True I still get data before the Launch Date.
Any help is greatly appreciated!

My suggestion is add one filter and add these filter conditions as if statements in calculated fields, This will be like processing inside tableau after fetching data from database instead of working directly on database.
Incase if you want to apply as filters then take 3 sheets and apply filters individually and combine sheets in dashboard.
Edit-----------------------------------------------------------------
create 3 calcualted fields:
1st calculated field:
if [rep_onboard_date]>=[parameter.Launch Date]
then table.field
2nd Calculated filed
if [user_application_date]>=[parameter.Launch Date]
then table.field
3rd Calculated Field
if [user_enrollment_date]>=[parameter.Launch Date]
then table.field
one condition is launch date should be parameter then create one more calculated field with parameter using lauch date an select true by placing on filter:
table.launch date> parameter.launch date

Related

How to filter by current month automatically on pivot table google sheets?

As a data analyst, I would like to see the report in a pivot table automatically for the current month, so that I can take a look at it and don't have to change the date filter manually.
This is the formula to show the first day of the current month. (Which is the criteria I need, first of the current month)
=EOMONTH(today(),-1)+1
It works when I put this formula in any cell.
But when I put it in the pivot "filter by condition" option it doesn't work.
This is what I tried.
Text is exactly =EOMONTH(today(),-1)+1 (In formula box)
The date is exactly =EOMONTH(today(),-1)+1 (In formula box)
Here a screenshot of the options
Any help will be greatly appreciated.
I've never had great luck with the pivot table filter criteria in Sheets, I typically filter the data first if it's more advanced or use aggregating functions. In the Sheets pivot tables are better for quick analysis than dashboards.
There's probably a few ways to do it, but one of the easier ways would be to duplicate the data tab, clear the data and use a filter function to retrieve data. Update the Pivot table data source to the new tab. This will always only be the current month's data.
Basically you filter the data before the pivot table, with the [filter function][1].
=Filter(data , [date col]>=EOMONTH(today(),-1)+1 , [date col]< date(year(today()), month(today())+1,1)
You can also add a month column to the data and then filter on that column, however each month you would need to update the month filter in the pivot table.
=date(year([date cell]),Month([date cell]),1)
If you're using it for a 'dashboard' of sorts, I would generally recommend to create it yourself with aggregating formulas (sumifs, countifs, ect) and then you can use the more complex filters.
try custom formula:
=MONTH(A2)=MONTH(TODAY())
where A2 is first cell of column containing valid dates
You can try to Filter by a Custom Formula:
=month(DatePurchase)=month(TODAY())
Where DatePurchase is the Field Name.

Tableau Count Distinct when graphed shows chronological last date, when deduplicated, not first

I'm doing a break fix on a Tableau report visualization that shows the outcomes of clients by client id for a given year by showing a running sum of distinct count of client id or RUNNING_SUM(COUNTD([ID])). The X axis of the visualization is the initial date of contact with the client. Occasionally, due to errors in the data or weird behavior, there are clients that have two initial dates, listed as two separate data rows where the column Initial Date will have different values but they will share an ID.
Currently, the visualization shows such people with their chronological last Initial Date and I need it to dedup such that the visualization shows them as starting from the chronological first Initial Date.
I could create a calculated field for if there are two IDs with multiple non identical Initial Dates then use the first, but I'm not sure how to create a calculated field that can groupby or otherwise check multiple dates per ID.
In Python/psuedo code, it would be something like
For ID in IDS:
if len(groupby.IDS.ID)>1:
then Initial_Date = min(InitialDate)
But I have to do the transformation in Tableau
Keep everything the same, but create a calculated field named "Initial Contact Date" with the calculation:
{FIXED [ID]: MIN(InitialDate)}
Then replace the date field on the X axis (Columns) with this date field instead.
That LOD Expression loops through all rows given the ID, and returns only the min one.

How to show previous value based on selection from quick filter in Tableau

I like to show the previous period value with difference based on the period selected from the quick filter in Tableau.
For example:
If I select 2019 from quick filter I would like to see the value with the difference compared with previous period (i.e 2018)
(means 2019 (from quick filter) vs 2018).
You can't access a quick filter value directly in tableau instead use parameters where you can access the parameters in calculated fields.
For this requirement LoD serves the purpose, where use a Fixed LoD which will bypass the filtering and get you the values.
For E.g
{Fixed :Sum(if year = 2018 then sales end)}
In worksheet you have 2019 value then use a calculated field to find the difference
Edit-------------------------------------
If quick filter is a single value selection then you can subtract 1 from year field. like below:
{Fixed :Sum(if year = [datbasefield.year]-1 then sales end)}
Instead of using a filter to select your period, use a parameter. Then you can use a calculated field to filter to both the year selected by the parameter and the prior year.
If you then want to calculate the difference between two years, you can use a Quick Table Calc (right click on the green measure pill on whatever shelf you are using).
If you then want to hide that first (empty) value, use the hide command or a table calc filter.
So in a nutshell, read about parameters and table calculations in the on-line help

Tableau Aggregation of Groups over Fixed Level of Detail

For some reason when I try to group a field created by a fixed level of detail groups containing more then one item disappear from the view.
The basic set up is that there are 'unique event IDs' which are RCIPID which have one or two dates associated with them (some events have two separate dates that are non-linear). There is a 'follow up' date which is tied only to the event location and not the RCIPID, but each RCIPID has only one location.
I've joined the 'follow up' data to the main file based on the location. The below computations [NTC Submission Date] is the date of the event. [Live Date] is the date of the followup. The computations correctly give the number of days after the event that the follow up happened.
However when I try to do a unique count of NTC Date (Or RCIPID) and then group the computations any group with more then one day disappears.
FP - Straight Diff
DATEDIFF('day', [NTC Submission Date], [Livedate])
FP - Remove Negatives
IF [FP - Straight Diff]<0
Then DateDiff('day',[NTC Submission Date],TODAY())
ELSE
[FP - Straight Diff]
END
FP - Days after NTC
{FIXED [Rcip Id], [NTC Submission Date]: MIN([FP - Remove Negatives])}
It works when it is not grouped together
But as soon as I group it all of the groups with more then one day disappear.
Any and all help is greatly appreciated. I think it has /something/ to do with being a dimension, but I honestly don't know what.
The goal is a bar chart similar to the second one, but with the groups "4-5 Days", "6-10 Days", "11-20 Days", and "Over 20 Days" visible. Those values do exist in the data and if I change the view to show the day instead of a count it shows the proper calculations:
EDIT: Using a calculated field instead of groups did not work. Trying a concatenated RCIPID and NTC Submission Date also did not have an effect.
I'm not a huge fan of the group by feature in Tableau as it has give me some unexpected behavior in the past.
There are a few approaches I would recommend trying. One is spelled out well here by using the bin functionality built into tableau. https://community.tableau.com/thread/188952
It sounds like you have some irregular bin sizes you're looking for, in which case you could create a separate calculated field with a series if else statements based on the range of [FP - Days after NTC] and assign a string to each 'grouping'
Lastly, I've not done an LOD of this style with two dimensions "FP - Days after NTC". You only appear to have COUNTD(submission days) on the view shelf. I would verify that you are getting the results you are expecting. And if not, you could create a separate calculated field that is a concatenation of [Rcip Id] and [NTC Submission Date] on which to based your LOD calculation, and then you can use COUNTD on that new field.
EDIT: It was suggested to try using a computed field instead of a group and/or concatenate RCIPID and NTC Date. I tried both and neither affected the result.

Tableau - Filter/Parameter For Different Date Ranges

I am trying to set up a filter or parameter for different date ranges in Tableau, such as:
Previous Week
Previous 4-Weeks
Previous 8-Weeks
based on the most recent data in the database. Is this possible?
Edit:
I should have been more clear here.
Is it possible to only have these options in the filter and have it based on the maximum date in the database?
Update
Based on your comment and updated question, you can do it as you intend, though it isn't as straight-forward.
NOTE: I did this very quickly and with a random data set, so it will be important for you to test this thoroughly with your data set.
Steps:
Create a parameter control that the users will use to change the selected date range. I created this as a list of strings with values that I can use directly in a calculated (after simple casting):
Create a calculated field that you will use as a filter that references the selection of the parameter control. It tests to see if the difference (in weeks) between the maximum date in the view and the date of any given row is less than the value of the parameter.
Calculation: INT([Date Filter Parameter]) > DATEDIFF("week",ATTR([Date Field]),WINDOW_MAX(MAX([Date Field])))
Place the calculated field in the filter box and set it to True.
You will be able to filter your data like so:
Original Answer
Yup - that is built into Tableau.
Add your date to the filter and select the "Relative Date" option:
You can set the defaults - users can change these later:
Then just "Show Filter":