Reputation: 572
I have 2 columns in my tableau, user_id
and createdAt
. user_id
as the id of the users, and createdAt
as the date transaction happen.
This is my tableau
I take this user_id = 60 as the example, so I have 2 filters, for the conditions users (PUL : true)
and date_range : true so the data will appear on date range
on my tableau, i made calculated field called datediff with this query
DATEDIFF('day',LOOKUP(MIN([Created At]),-1), MIN([Created At]))
so this calculated field has a function to count the different day between transaction for each users in date range (on this case, i choose range between '2020-01-01' until '2020-01-31')
as you can see,on date range for user_id 60 has 2 transactions, its january 10 and january 31, and for that reason, its 21 day different between those date. but if i put out the date_range filter you can see all the date of transaction for user_id = 60, you can see on this
as we know, before the date range, user_id = 60 has did the transaction on 24th december 2019, which means 17 days behind.
my question is, how to made the time difference between the transaction on first date in date_range, and compare it to last transaction before date range, so when i put the date_range filter, on january 10th 2020 (for user_id = 60) its also appear the 17 days time difference on column january 10th 2020 (because its compare with last date transaction before the date range which means on 24th december 2019).
which part i should edit or add?
Upvotes: 1
Views: 1635
Reputation: 26238
I have used sample data previously taken by me to solve your another problem.
sample data used
Create a calculated field date for filter
as
lookup(min(([Trans Date])),0)
Right-click this measure and click convert to continuous
use this field as filter instead, you will get what you want.
Two screenshots
and filtered view
EDIT: Since you have used parameters, use this calculation in date range
field instead
lookup(min(([Trans Date])),0) >= [Start date] and
lookup(min(([Trans Date])),0) <= [End date]
see this screenshot
Needless to say trans date
is your created at
field.
Upvotes: 1