2 Replies Latest reply on Mar 8, 2017 8:49 PM by Shinichiro Murakami

# Logical Lookback Calculation

I'm interested in calculating how many people who had 7 or more days of inactivity yesterday came back today.

My x-axis is the date and my strategy was the following calculated field,

```SUM(IF [date] - 1 AND [days_since_last_activity] >= 7 THEN [daily_active_users] END)
```

but of course date - 1 is never a true statement. What I want to say is:

SUM(IF day_since_last_activity] >= 7 WHEN yesterday THEN [daily_active_users END)

Any recommendations on how to do this in Tableau?

Thanks!

• ###### 1. Re: Logical Lookback Calculation

Hi

Use dateddiff finction

like if dateddifference((date-1) ,day since last activity) >= 7 then .... end

Thanks

Nipun

• ###### 2. Re: Logical Lookback Calculation

Hi Phillip

Here is my approach with LOD.

[Last Date by User]

{fixed [User]: max([Date])}

[2nd Last date by User]

{fixed[User]:max(if [Date]<[Last Date by User] then [Date] end)}

[User Criteria]

if [Last Date by User]=[Parameter instead of Today]

and  [Last Date by User]-[2nd Last date by User] >8 then

"Come back today" end

You can use today() instead of "Parameter~" in real environment.

Thanks,

Shin