Reputation: 163
I'd like to find the reactivation date after someone had last been inactive for 365 days.
There are two tables:
I used the following Dax formula to get the "last login date"
Last Login Date = MAXX(RELATEDTABLE('Login Table'), 'Login Table'[Login Date])
Any help would be greatly appreciated.
Upvotes: 1
Views: 511
Reputation:
One way to solve this is by using multiple measures and columns.
For your Login Table, add a new calculated column with the following definition:
Previous Login = CALCULATE(MAX(LoginTable[Login]), FILTER(LoginTable, LoginTable[User] = EARLIER(LoginTable[User]) && LoginTable[Login] < EARLIER(LoginTable[Login])))
This will create a new calculated column in your Login Table which adds the date of the previous login to your table. (My Login Date column is called Login, therefore you might need to change this)
Day Difference = DATEDIFF(LoginTable[Previous Login], LoginTable[Login], DAY)
Is Reactivated = IF(DATEDIFF(LoginTable[Previous Login],LoginTable[Login], DAY) > 360, 1, 0)
Reactivate = IF(LoginTable[Is Reactivated] == 1, LoginTable[Login], BLANK())
Table = GROUPBY(LoginTable, LoginTable[User], "Last Login", MAXX(CURRENTGROUP(), LoginTable[Login]), "Last Reactivation", MAXX(CURRENTGROUP(), LoginTable[Reactivate]))
A lot of steps could be put into one steps but this way, it is simpler to understand and troubleshoot.
Hope this helps!
Upvotes: 1