Record the previous day's figure
Hello
There is a DB for a gaming club, and to calculate the result for the day, you need to rewrite the counter indicators of the previous day. In order not to do this manually, we use a formula that automatically copies the indicators of the previous day
let c := number(Id);
let bc := last((select 'Slot Estimation' where number(Id) < c) order by number(Id));
first(select 'Slot Estimation' where Id = bc).'Coin In - Close Indicator'
The problem is that when we create a new record of the same day for the next slot, it also copies this indicator of the previous slot, not taking the indicator from the previous day from the same slot, but taking it from the slot that was filled before it, without taking into account the fact that the name does not match.
I think I need to add a record in the formula, or a restriction so that only from the previous day
6 replies
-
can you post a sample DB? if you can use a relationship then you can remove the need to match 'names'.
-
said:
The problem is that when we create a new record of the same day for the next slot, it also copies this indicator of the previous slot, not taking the indicator from the previous day from the same slot,I think this is happening because you are using record Ids, when you need to be filtering on Room and Number. If I am correct, when a new record is created in Slot estimation, you want to find all records with similar Room and Number, then find the previous day data for Coin-In/Out - Close Indicator.
Try:
let c := this; let bc := last((select 'Slot Estimation' where Room = c.Room and Number = c.Number and Date1 < c.Date1) order by Date1); bc.'Coin In - Close Indicator'
You don't need to the last select since bc is already pointing to a record. You can just use it directly.
Content aside
- Status Answered
- 4 days agoLast active
- 6Replies
- 41Views
-
2
Following