Gremlin: how can I create a dynamic filter to only show results that have a date later than 2 days from now? - orientdb

I have vertex "project" with properties "name" and "createdDate". I want to dynamically filter the projects to only show those that were created in the last two days, by "name", without having to hardcode the date into the filter. Is this possible?
I have this so far, which is not giving me an error but not producing results:
g.V().hasLabel('project').has('createdDate',gt('{LocalTime.Now()}'-2))
If I try this, I see all results but I want to filter by date:
g.V().hasLabel('project').has('createdDate',lt('{LocalTime.Now()}'))

Related

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.

Get full date range of linked field in tableau

Gif of problem
I am currently working on a dashboard in tableau, which shows the count of New-User-Signups and Interactions side-by-side given different date windows. The first New-User-Signup happened before the first Interaction, and the last Interaction happened after the last User Signup.
In order to choose a date window, I linked the date fields in both data sources, and made a date filter, which I applied to all worksheets using related data sources.
However, depending on which "date" field I choose, (from the User Signup table or the Interaction table), the "All Dates" option of the date filter only goes from start to end of that data source's date range.
No matter what I try, I exclude some entries in either one graph or the other. How can I make the "All Dates" filter go from the minimum first date between both data sources, to the maximum last date between the two data sources?
I run into this issue a lot with the data that I use. The problem is that the filter will only be able to contain dates that are in the dataset it is created off of, even if you link the data sources. When I run into this issue, I use parameters instead.
You can find instructions here:
https://kb.tableau.com/articles/howto/creating-a-filter-for-start-and-end-dates-parameters

Filter multiple views with different dates on one parameter issue

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

Sorting Data by Latest Date, selecting top 10 and charting (v. 10.0.1)

This is the data table that I have created
I need to sort the data by 'April2017' in descending order and then select the top 10 projects.
When we select top10 basis April2017, the output should be
Instead what I get is
Here is what I've tried out so far,
Created a calculated field
Calculation1 = iif([Year_Month]=MAKEDATE(2017,4,1),[Claim Count],0)
Sorted Projects based on 'Calculation1'
Drag Project to Filter and select Top10 based on sum([Calculation1])
I am unable to understand how the top10 here is being derived.
Where am I going wrong?
The chart that I am trying to get should be similar to
Please help me with this problem.
You can filter to a selected portion of data in a calculation and use as desired. So create a calculated field called, say April_2017_Foobars, defined as:
if datetrunc('month', [Year_Month]) = #04/01/2017# then [Foobars] end
This field return [Foobars] for the April 2017 rows and null for other rows. Nulls are ignored by aggregate functions, so if you aggregate with SUM() or AVG() etc, the effect is to filter to April 2017 for that field alone.
Then you can use April_2017_Foobars for sorting and defining top filters for your Project field. This is a very general technique that is useful in all kinds of situations.
You can generalize it a bit to use a parameter for the special month rather than hard code it - or use an LOD calc to find the last month in your dataset if you always intend to use the latest month.
P.S. You can use the makedate() function instead of a date literal if you prefer and your data source supports that function. Might avoid any confusion about date literal formats being different in various countries.
create Calculation1 field: iif([Year_Month]="April 2017",[Number],0)
sort Project in descending order on Calculation1 Sum
drag Project to filters, and do Top > By Field > Top: 10 by Calculation1 Sum

User-defined date range for Access query pulling outside date range

I have an Access 2007 database that requires a query be run every week to gather every record that was worked on the prior week. The current setup is:
I have a query where the date range's WHERE criteria is: Between [Forms]![frm_Menu]![txt_fromdate] And [Forms]![frm_Menu]![txt_todate]+"1"
"fromdate" and "todate" text boxes in frm_Menu are unbound text boxes. "fromdate" has an AfterUpdate event that fills in "todate" with the date chosen in "fromdate" plus 6 days.
frm_Menu has a button for running the query after "fromdate" and "todate" are filled in.
The issue is, when I run the query for a week's worth of records, I get entries outside the selected date range. For example, if I have "3/1/2015" in the "fromdate" text box and "3/7/2015" in the "todate" text box, I'll receive the results from 3/1 to 3/7, but I'm also getting results from 3/10, 3/11, and 3/12.
At first, I thought it might be reading "3/1/2015" as "3/1x/2015," but that doesn't explain why I'm ONLY getting extra results from 3/10 through 3/12 and not 3/13 through 3/19 as well.
Does anyone know what might be causing this? To work around this problem, I've just been running a query that gathers EVERYTHING and then filtering out what's need in Excel before sending it over. Ideally, I'd like for the person who needs this report to be able to open the database themselves, pick the date range they need, and then export the query results from Access.
It turned out I had the data type for the Dates column as Text instead of Date/Time. Retried the same query after changing the column to Date/Time and it worked perfectly. Just a PEBKAC error.