Forum Discussion
Index column based on date, multiple entries excluded based on time
- 8 years ago
Step 1:
Index =
VAR UserFirstDate = MINX(FILTER('Events Completion';'Events Completion'[user_id] = EARLIER('Events Completion'[user_id]));'Events Completion'[DateTime])
RETURNDIVIDE (DATEDIFF(UserFirstDate ;'Events Completion'[DateTime];DAY);1)+1
Step 2:
Rank =
VAR d = 'Events Completion'[Index]
VAR c = 'Events Completion'[user_id]
RETURN
CALCULATE (
RANK.EQ ( d; 'Events Completion'[Index]; ASC );
FILTER ( ALL ( 'Events Completion'); 'Events Completion'[user_id] = c ))
Hi Phil_Seamark,
I used:
Index =
VAR UserFirstDate = MINX(FILTER('Events Completion';'Events Completion'[user_id] = EARLIER('Events Completion'[user_id]));'Events Completion'[date] & " " & 'Events Completion'[time])
RETURN DIVIDE(DATEDIFF(UserFirstDate ;'Events Completion'[date] & " " & 'Events Completion'[time];HOUR);24)+1
but somehow that didn't work. See the example hereunder.
It gave back negative results and decimals which, in addition, are not the same for the same day...
Any clue?
I made some changes:
DayOfUse = VAR UserFirstDate = MINX(FILTER('Events Completion';'Events Completion'[user_id] = EARLIER('Events Completion'[user_id]));'Events Completion'[DateTime])
RETURN DIVIDE(DATEDIFF(UserFirstDate ;'Events Completion'[DateTime];DAY);1)+1
But this results in the day number after first use. So startdate gives value 1. Second date is af day 10 gives value 10.
How to change the second (thirth, forth, etc) day into value 2?
- Phil_Seamark8 years ago
Microsoft Employee
Hi Atseaukes
Is the time of day important?
Eg, if the first item starts at 2pm (in the afternoon) on a Monday.
In that case, what value would you give to an event that took place at 10am on the following Wednesday, and also to one that took place at 8pm on the same Wednesday?
Do you need to track that one of those events was less than 48 hours while the other is more than 48 hours to give a different result? Or should both have the same value because the time component is not important?
- Atseaukes8 years agoFrequent Visitor
Hi Phil_Seamark,
The time of day is not important.
Monday would have value 1. The following Wednesday at 10am would have value 2, just like the event at 8pm (value = 2).
- Phil_Seamark8 years ago
Microsoft Employee
ok, then does this get closer?
Column = VAR UserFirstDate = MINX(FILTER('Table1','Table1'[user_id] = EARLIER('Table1'[user_id])),'Table1'[date] ) RETURN DATEDIFF(UserFirstDate ,'Table1'[date] ,DAY)+1