0

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

null
    • Fred
    • 2 mths ago
    • Reported - view

    can you post a sample DB? if you can use a relationship then you can remove the need to match 'names'.

      • iliper LTD
      • iliper_LTD
      • 2 mths ago
      • Reported - view

      Thank you very much for helping  

      I am sharing part of the table, at the top I described the problem.

      • Fred
      • 2 mths ago
      • Reported - view

      can you tell me where this code is?

      • iliper LTD
      • iliper_LTD
      • 2 mths ago
      • Reported - view

      Good morning  

      open any day in "finally estimation" + "choice"=slot + table "slots" open any record and check feilds

      "Coin In  - Open Indicator"  and "Coin Out - Open Indicator"

      When you create a new day to test, first create a day in the table "GM Table"  (use the button inside the table and create a new day)

    • Fred
    • 2 mths ago
    • Reported - view
     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.

      • iliper LTD
      • iliper_LTD
      • 2 mths ago
      • Reported - view

      Thanks a lot  

      everything works great

Content aside

  • Status Answered
  • 2 mths agoLast active
  • 6Replies
  • 43Views
  • 2 Following