I have a requirement and I think a possible solution, but I wanted to validate it first to ensure its the best approach.
There is currently a view that needs 2 new fields added. The first field will be spread in such a way that no day has more than 24 in it. The allocation will begin on the start date and continue each calendar day until the hours required are fully consumed. A new date entry will be made for each day the machine is in use.
So for example a machine requires 80 hours to finish a part. The new output will create 4 identical records except for the new date and hours required fields, as shown below.
| Date | Hours required |
|---|---|
| June 1 | 24 |
| June 2 | 24 |
| June 3 | 24 |
| June 4 | 8 |
My thoughts were to create a table function and use a while loop to continuously check the current field that has the required hours and check if its greater than 0 and subtract 24 until it was less than 24 in which that would be the final entry. It would also increment the start date by 1 day each time it went through the loop. I would then put the table function in a graphical view and then the front end could consume it.
Any feedback would be greatly appreciated!