Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey guys !
I was wondering how to write function (in front or in data load editor) that will calculate average spending of Customer BUT starting to count months from the first transaction customer made;
basic easy example in printScreen Below:
Hello Ena,
Your snapshot is missing customer identifier, so I added one.
You can get average in script as below:
Data:
LOAD customer, sum(spend) / (max(customerCounter) - min(if(spend>0,customerCounter))+1) as average group by customer;
LOAD customer, month, spend, AutoNumber(recno(),customer) as customerCounter
INLINE [
customer, month, spend
1,Jan,0
1,Feb,0
1,Mar,0
1,Apr,100
1,May,0
1,Jun,200
1,Jul,150
1,Aug,0
1,Sep,0
1,Oct,100
1,Nov,200
1,Dec,0
1,Jan,100
1,Feb,0
1,Mar,0
1,Apr,0
2,Jan,0
2,Feb,50
2,Mar,0
2,Apr,50
2,May,0
2,Jun,100
2,Jul,50
2,Aug,0
2,Sep,0
2,Oct,200
2,Nov,100
2,Dec,0
2,Jan,100
2,Feb,400
2,Mar,0
2,Apr,50
];