Forum Discussion
DATEDIFF between duplicate IDs
- Anonymous9 years ago
So... we take the max(date sold) minus min(date sold) giving us the total # of days between sales, then divide by the number of sales (minus 1)... and that gives the average number of days between sales? I think?
Jan 1, 2017
Jan 9, 2017
... 8 days between sales -- Jan 9 - Jan 8 / (2 sales - 1) = 8
Jan 1, 2017
Jan 2, 2017
Jan 9, 2017
... still 8 days, but now with another sale, we get average of 4 days. The exact date off the "middle" sale doesn't matter, at least in my head!? Currently Jan2-Jan1=1, Jan9-Jan2=7, (7+1)/2=4 ?
Avg Days Between Sale := DIVIDE(MAX(MyTable[SaleDate]) - MIN(MyTable[SaleDate]), COUNTROWS(MyTable) - 1)Maybe?! :)
- Anonymous9 years ago
Hi again,
Qucik update, it turns out that my technical indications were incorrect and the sales are not going to coming through this way.
However, intrigued by the suggestion I've had a quick look through but can't seem to get it to work:
ID Date Sold Time taken to sell 1 01/01/2017 0 1 03/01/2017 2 3 05/01/2017 0 Average Days to Sell 3 10/01/2017 5 3,5 Jan10-Jan1 / 2 sales = 5? Jan10-Jan1 / (2-1) sales = 10? Many thanks for your help anyway.
Matt
What if the same ID comes up ... 3 times? 47 times?
Hi Anonymous
Good question! The time taken between each date (sale) should be included in the average calculation.
A product (the same ID) can be sold numerous times.
Let me know if you need any further information!
Thanks,
Matt
- Anonymous9 years agoNot applicable
So... we take the max(date sold) minus min(date sold) giving us the total # of days between sales, then divide by the number of sales (minus 1)... and that gives the average number of days between sales? I think?
Jan 1, 2017
Jan 9, 2017
... 8 days between sales -- Jan 9 - Jan 8 / (2 sales - 1) = 8
Jan 1, 2017
Jan 2, 2017
Jan 9, 2017
... still 8 days, but now with another sale, we get average of 4 days. The exact date off the "middle" sale doesn't matter, at least in my head!? Currently Jan2-Jan1=1, Jan9-Jan2=7, (7+1)/2=4 ?
Avg Days Between Sale := DIVIDE(MAX(MyTable[SaleDate]) - MIN(MyTable[SaleDate]), COUNTROWS(MyTable) - 1)Maybe?! :)
- Anonymous9 years agoNot applicable
Interesting approach, let me have a play around and see what the results are!
Thank you for the suggestion Anonymous
- v-huizhn-msft9 years agoMicrosoft Employee
Hi Anonymous,
If you still do not resolved your problem, you'd better post some sample table for further analysis. And welcome to share your workaround and mark the helpful reply as answer if you have resolved it.
Best Regards,
Angelia
- Anonymous9 years agoNot applicable
Hi again,
Qucik update, it turns out that my technical indications were incorrect and the sales are not going to coming through this way.
However, intrigued by the suggestion I've had a quick look through but can't seem to get it to work:
ID Date Sold Time taken to sell 1 01/01/2017 0 1 03/01/2017 2 3 05/01/2017 0 Average Days to Sell 3 10/01/2017 5 3,5 Jan10-Jan1 / 2 sales = 5? Jan10-Jan1 / (2-1) sales = 10? Many thanks for your help anyway.
Matt