Actualización en otra tabla/Update in another table

Hola a todos,

Tengo dos tablas una que registra los pesos de cada animal (Pesadas) y otra con la identificación de cada animal (Bases Caravanas). Un animal se puede pesar varias veces. Lo que estoy tratando de hacer es que cada vez que se pesa un animal en la tablas Pesadas, en la tabla Bases Caravanas se registre el ultimo registro de peso y la fecha. Entiendo que debería hacer un doble filtro entre el IdAnimal y la última fecha de registro y que me devuelva ese registro de peso en la tabla de Bases Caravanas, pero no logro hacerlo.

De antemano, muchas gracias!

Hello everyone,

I have two tables, one that records the weights of each animal (Pesadas) and another with the identification of each animal (Bases Caravanas). An animal can be weighed several times. What I am trying to do is that every time an animal is weighed in the Pesadas tables, the last weight record and the date are recorded in the Caravan Bases table. I understand that I should do a double filter between the IdAnimal and the last registration date and return that weight record in the Caravan Bases table, but I can't do it. I've been trying with bot, but i'm doing a mess

 

THANKS A LOT!!!

111.png222.png

Solved Solved
0 3 233
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Create an action for the Bases Caravanas table called (e.g.) Get latest weight of this animal, of type Data: set the values of some columns in this row, to set the value of the Ultima Peso column using this expression:

SELECT(
  Pesadas[Peso],
  AND(
    ([_THISROW].[IdAnimal] = [IdAnimal]),
    ISBLANK(
      FILTER(
        "Pesadas",
        AND(
          ([_ROWNUMBER] <> [_THISROW-1].[_ROWNUMBER]),
          ([IdAnimal] = [_THISROW-1].[IdAnimal]),
          (
            ([Fecha] + ([Hora] - "00:00:00"))
            >= ([_THISROW-1].[Fecha] + ([_THISROW-1].[Hora] - "00:00:00"))
          )
        )
      )
    )
  )
)

Create another action, for the Pesadas table, called (e.g.) Update latest weight for this animal, of type Data: execute an action on a set of rows, with a Referenced Table of Bases Caravanas, a Referenced Rows expression of LIST([IdAnimal]), and a Referenced Action of the action created above (Get latest weight of this animal).

In the configuration of the form view of the Pesadas table used to record the latest weight (e.g., Pesadas_Form), set the Form Saved event action to the Update latest weight for this animal action created above.

View solution in original post

3 REPLIES 3

You should have a bot triggered by the addition of new Pesadas row, to update the columns of the corresponding animal row in the Bases table.

Steve
Platinum 4
Platinum 4

Create an action for the Bases Caravanas table called (e.g.) Get latest weight of this animal, of type Data: set the values of some columns in this row, to set the value of the Ultima Peso column using this expression:

SELECT(
  Pesadas[Peso],
  AND(
    ([_THISROW].[IdAnimal] = [IdAnimal]),
    ISBLANK(
      FILTER(
        "Pesadas",
        AND(
          ([_ROWNUMBER] <> [_THISROW-1].[_ROWNUMBER]),
          ([IdAnimal] = [_THISROW-1].[IdAnimal]),
          (
            ([Fecha] + ([Hora] - "00:00:00"))
            >= ([_THISROW-1].[Fecha] + ([_THISROW-1].[Hora] - "00:00:00"))
          )
        )
      )
    )
  )
)

Create another action, for the Pesadas table, called (e.g.) Update latest weight for this animal, of type Data: execute an action on a set of rows, with a Referenced Table of Bases Caravanas, a Referenced Rows expression of LIST([IdAnimal]), and a Referenced Action of the action created above (Get latest weight of this animal).

In the configuration of the form view of the Pesadas table used to record the latest weight (e.g., Pesadas_Form), set the Form Saved event action to the Update latest weight for this animal action created above.

Top Labels in this Space