¡Le damos la bienvenida! Nos alegra que esté aquí. ¡Preséntese y conozca a sus colegas!

¿como tomar el ultimo registros en una base de datos?

Tengo una base de datos donde se ven los registros de tiempo de estancia un area.

Cada empleado requiere solicitar una autorizacion y no exceder un tiempo maximo de estancia en un un periodo de tiempo en esa area (ejemplo cada mes se le agregan 10 hr aunque esto varia del tipo de empleado).

Tengo una hoja llamada PROCESO que hace las automatizacion de solicitud y autorizaciones; una vez autorizadas pasan a otra base de datos ACEPTADOS.

Cuando existe una solicitud en mi hoja de PROCESO necesito "importar" el tiempo que le queda al empleado, ya que es una condicionante para que se procese su solicitud.

Es decir horas Horas iniciales - Horas solicitadas = Horas remanentes.

Si fuera una sola persona, esto se veria algo asi:

image.png

El problema es cuando son miles de datos; ya que en la siguiente solicitud deberia tomar las "Horas remanentes" del ultimo registro de mi base de datos ACEPTADOS, no se como jalar este ultimo registro dependiendo del numero de empleado.

image.png

Ayuda, que formula deberia usar para tomar la informacion de ejemplo

Intente con INDEX pero cuando solo hay un registro del "#Nomina" funciona, pero para otros casos me marca #NO MATCH

Esta es la formula que use:

=INDEX({ACEPTADOS Rango 1}, MATCH([# Nomina]@row, {ACEPTADOS Rango Horas remanentes}))

Gracias por su ayuda

Ana

Best Answer

  • jmyzk_cloudsmart_jp
    jmyzk_cloudsmart_jp Community Champion
    edited 05/18/25 Answer ✓

    Hi @AnaV

    Gracias por compartir tu caso tan claramente.

    Entiendo que necesitas obtener las últimas horas remanentes válidas de cada empleado desde la hoja ACEPTADOS, considerando solo los registros anteriores o iguales a la fecha de solicitud (F INICIO) en la hoja PROCESO.

    Solución sugerida con columna auxiliar:

    Agrega una columna auxiliar llamada Cantidad de registros, que cuenta cuántos registros válidos existen para el nombre correspondiente, con fecha igual o anterior a la solicitud.

    https://app.smartsheet.com/b/publish?EQBCT=fdc99cef28b14adfa0d3de7d72d52977

    image.png

    Fórmulas:

    Cantidad de registros

    =COUNT(COLLECT({ACEPTADOS Demo Sheet : Horas remanentes}, {ACEPTADOS Demo Sheet : NOMBRE}, NOMBRE@row, {ACEPTADOS Demo Sheet : F INICIO}, <=[F INICIO]@row))

    Horas remanentes válidas (en columna existente)

    =IF([Cantidad de registros]@row > 0, INDEX(COLLECT({ACEPTADOS Demo Sheet : Horas remanentes}, {ACEPTADOS Demo Sheet : NOMBRE}, NOMBRE@row, {ACEPTADOS Demo Sheet : F INICIO}, <=[F INICIO]@row), [Cantidad de registros]@row), "Sin datos")

    https://app.smartsheet.com/b/publish?EQBCT=0f92a8fb749341e7b7bacdefdda146b5

    image.png

    English

    Thanks for clearly outlining your situation.

    You need to pull the last valid remaining hours per employee from the ACEPTADOS sheet, considering only entries before or equal to the request date (F INICIO) in the PROCESO sheet.

    Suggested solution with a helper column:

    Add a helper column called Cantidad de registros to count how many valid records exist for the given name, dated on or before the request.

    Formulas:

    Cantidad de registros

    =COUNT(COLLECT({ACEPTADOS Demo Sheet : Horas remanentes}, {ACEPTADOS Demo Sheet : NOMBRE}, NOMBRE@row, {ACEPTADOS Demo Sheet : F INICIO}, <=[F INICIO]@row))

    Valid remaining hours (in your existing column)

    =IF([Cantidad de registros]@row > 0, INDEX(COLLECT({ACEPTADOS Demo Sheet : Horas remanentes}, {ACEPTADOS Demo Sheet : NOMBRE}, NOMBRE@row, {ACEPTADOS Demo Sheet : F INICIO}, <=[F INICIO]@row), [Cantidad de registros]@row), "Sin datos")

    This ensures you're pulling the most recent applicable value for each name without including future records.
    Let me know if you’d like help adapting this logic further.

Answers

  • jmyzk_cloudsmart_jp
    jmyzk_cloudsmart_jp Community Champion
    edited 05/18/25 Answer ✓

    Hi @AnaV

    Gracias por compartir tu caso tan claramente.

    Entiendo que necesitas obtener las últimas horas remanentes válidas de cada empleado desde la hoja ACEPTADOS, considerando solo los registros anteriores o iguales a la fecha de solicitud (F INICIO) en la hoja PROCESO.

    Solución sugerida con columna auxiliar:

    Agrega una columna auxiliar llamada Cantidad de registros, que cuenta cuántos registros válidos existen para el nombre correspondiente, con fecha igual o anterior a la solicitud.

    https://app.smartsheet.com/b/publish?EQBCT=fdc99cef28b14adfa0d3de7d72d52977

    image.png

    Fórmulas:

    Cantidad de registros

    =COUNT(COLLECT({ACEPTADOS Demo Sheet : Horas remanentes}, {ACEPTADOS Demo Sheet : NOMBRE}, NOMBRE@row, {ACEPTADOS Demo Sheet : F INICIO}, <=[F INICIO]@row))

    Horas remanentes válidas (en columna existente)

    =IF([Cantidad de registros]@row > 0, INDEX(COLLECT({ACEPTADOS Demo Sheet : Horas remanentes}, {ACEPTADOS Demo Sheet : NOMBRE}, NOMBRE@row, {ACEPTADOS Demo Sheet : F INICIO}, <=[F INICIO]@row), [Cantidad de registros]@row), "Sin datos")

    https://app.smartsheet.com/b/publish?EQBCT=0f92a8fb749341e7b7bacdefdda146b5

    image.png

    English

    Thanks for clearly outlining your situation.

    You need to pull the last valid remaining hours per employee from the ACEPTADOS sheet, considering only entries before or equal to the request date (F INICIO) in the PROCESO sheet.

    Suggested solution with a helper column:

    Add a helper column called Cantidad de registros to count how many valid records exist for the given name, dated on or before the request.

    Formulas:

    Cantidad de registros

    =COUNT(COLLECT({ACEPTADOS Demo Sheet : Horas remanentes}, {ACEPTADOS Demo Sheet : NOMBRE}, NOMBRE@row, {ACEPTADOS Demo Sheet : F INICIO}, <=[F INICIO]@row))

    Valid remaining hours (in your existing column)

    =IF([Cantidad de registros]@row > 0, INDEX(COLLECT({ACEPTADOS Demo Sheet : Horas remanentes}, {ACEPTADOS Demo Sheet : NOMBRE}, NOMBRE@row, {ACEPTADOS Demo Sheet : F INICIO}, <=[F INICIO]@row), [Cantidad de registros]@row), "Sin datos")

    This ensures you're pulling the most recent applicable value for each name without including future records.
    Let me know if you’d like help adapting this logic further.

  • AnaV
    AnaV ✭✭

    Estimado @jmyzk_cloudsmart_jp,

    Muchas gracias por su mensaje…. Funciono la sugerencia de la columna auxiliar!!

    hice una variacion. Asigne un consecutivo ACEPTADOS ORDEN, esto me ayudara a que los siguientes se iran formando por orden de aparición.

    Posteriormente hice la busqueda tomando referencias cruzadas: El numero de nomina, el MAX del consecutivo

    =INDEX(COLLECT({ACEPTADOS Horas remanentes}, {ACEPTADOS #NOMINA}, [# Nomina]@row, {ACEPTADOS ORDEN}, MAX(COLLECT({ACEPTADOS ORDEN}, {ACEPTADOS #NOMINA}, [# Nomina]@row))), 1)

    Gracias por la asistencia!!

Ayuda y aprendizaje