Calculate Cumulative Time with Code
Hello everyone, I need a piece of code to calculate the continuous days of placing orders for sales (using weeks as the time interval). For example, today is Friday, and if I have orders from Monday to Thursday, then if there is an order today, it will return "5 consecutive days of orders". Otherwise, if there is no order today, it will show "4 consecutive days of orders", and tomorrow it will display "0 consecutive days", and the accumulation will start again. The count resets every week. I've written the code I've tried below. Thanks in advance!
4 replies
-
I am probably missing something in my suggestion but couldn't you do something like:
You would need to create two new formula fields in Orders:
1) called Week and uses the week() command
2) called WeekDay and uses the weekday() command
Then you can quickly find the Orders that match the current week, line 1.
Line 2, finds the unique number of days that is in the week.
Line 3, counts the number of days found.
With a data set of:
The formula returns 4.
You can swap out 12 for week(today()) so it will always show the latest week.
Content aside
- Status Answered
- 4 mths agoSun, October 27, 2024 at 12:30 AM UTCLast active
- 4Replies
- 47Views
-
2
Following