Assign value from previous variable

hi everyone
i did program rule :-
the action is assign value to data element
the variable source data element from previous event
It works well if there is a difference of one day or more between events, but if two events occur on the same day, it does not take the value of the previous event on the same day, but rather takes the value of the event that precedes it by one day.