Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi ,
I need to calculate the repeat callers who have called within 3 days of their first call as shown below.
A person will be considered for that date if he calls on that particular date only.
Similiarly for 7 days.
try this:
data:
load * inline [
customer, callDate
A, 1/1/2023
A, 1/3/2023
A, 1/4/2023
A, 1/5/2023
A, 1/9/2023
B, 2/1/2023
B, 2/7/2023
B, 2/9/2023
];
NoConcatenate
tmp:
load distinct * Resident data;
inner join (tmp)
load customer, callDate as repeatCallDate
Resident tmp;
NoConcatenate
repeatCalls:
load *
Resident tmp
where repeatCallDate > callDate
and repeatCallDate <= callDate+3;
NoConcatenate
hasRepeatCalls:
load distinct customer, callDate, 'yes' as hasrepeatCalls Resident repeatCalls;
left join (data)
load * Resident hasRepeatCalls;
drop table tmp, repeatCalls, hasRepeatCalls;
repeatCalls table holds all repeat dates that qualify as repeat calls. you can expand on this to implement the totals by just aggregating it. from the sample data: