Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bbruegge
Regular Visitor

Mostrar la fecha de inicio y la fecha de finalización de un bloque de vacaciones

Hola a todos

Estoy teniendo una mesa con datos de vacaciones de muchas personas diferentes. Se ve así:

NombreFechaEstado
Fred2020.08.06día festivo
Fred2020.08.07día festivo
Fred2020.09.24día festivo
Fred2020.09.25día festivo
Ben2020.08.06día festivo
Ben2020.08.07día festivo

Me gustaría generar una tabla, que muestra la fecha de inicio y la fecha de finalización de los bloques de vacaciones de cada persona.

NombreEstadoFecha_inicialFecha_final
Freddía festivo2020.08.062020.08.07
Freddía festivo2020.09.242020.09.25
Bendía festivo2020.08.062020.08.07

¡Gracias de antemano!

1 ACCEPTED SOLUTION

@bbruegge

Está bien 🙂

He creado algunos datos de origen en función de sus entradas y he realizado el resumen esperado mediante Power Query. Puede seguir los mismos pasos para incorporarlo al modelo.

Puede descargar el archivo: HERE



Fowmy_0-1596655282442.png

________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

YoutubeLinkedin


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

10 REPLIES 10
Fowmy
Super User
Super User

@bbruegge

Cree una nueva tabla: pestaña Inicio > Nueva tabla y copie el código debajo, asegúrese de que los nombres de tabla y los nombres de campo coincidan con los suyos.

Holidays By Employees = 
FILTER(
    SELECTCOLUMNS(
        GENERATE(
            'Table',
            ROW(
                "_Name" , 'Table'[name],
                "_StartDate",
                VAR CD = 'Table'[date]
                VAR PDATE = CALCULATE(MAX('Table'[date]), 'Table'[date] < CD, ALLEXCEPT('Table','Table'[name]))            
                RETURN
                IF(DATEDIFF(PDATE,CD, DAY) = 1 , PDATE, BLANK() )
            )
        ),
        "Names", [_Name],
        "Holidays", 'Table'[status],
        "End Date", 'Table'[date],
        "Start Date", [_StartDate]
     
    ),
    [Start Date] <> BLANK()
)

Fowmy_0-1596612948187.png

________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

YoutubeLinkedin


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy

Gracias por su respuesta.

No está funcionando correctamente. ¿Tienes una idea de lo que estoy haciendo mal?

(TU - vacaciones)

bbruegge_0-1596619343569.png

@bbruegge

Creé la tabla basada en los datos de ejemplo que proporcionó en su pregunta. Asegúrese de que coincida con sus datos reales.
Puede compartir un ejemplo similar a los datos reales que desea comprobar.

________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

YoutubeLinkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Estos son mis datos:

bbruegge_0-1596620757110.png

Y este es el código que estoy usando para la nueva tabla:

Start- und Enddatum = 
FILTER(
    SELECTCOLUMNS(
        GENERATE(
            Schichtplan,
            ROW(
                "_Mitarbeiter" , Schichtplan[Mitarbeiter],
                "_von",
                VAR CD = Schichtplan[Datum].[Date]
                VAR PDATE = CALCULATE(MAX(Schichtplan[Datum].[Date]), Schichtplan[Datum].[Date] < CD, ALLEXCEPT(Schichtplan,Schichtplan[Datum].[Date]))            
                RETURN
                IF(DATEDIFF(PDATE,CD, DAY) = 1 , PDATE, BLANK() )
            )
        ),
        "Mitarbeiter", [_Mitarbeiter],
        "Status", Schichtplan[Schicht_Abkrz],
        "bis", Schichtplan[Datum].[Date],
        "von", [_von]
     
    ),
    [bis] <> BLANK()
)

@bbruegge

¿Puede compartir el archivo PBIX con algunos datos?

________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

YoutubeLinkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy

No tengo permiso para cargar archivos adjuntos. Es por eso que tuve que usar mi cuenta de Google Drive:

pbi_shiftschedule_holiday.pbix

¡Gracias!

@bbruegge

A continuación se muestra el ejemplo que compartió en su pregunta, basado en eso, esperaba que el inicio y el final de cada nombre llegaran como un conjunto más, ejemplo Fred tiene dos conjuntos de intervalos de fechas aquí, no fechas consecutivas. En el archivo, ha cargado datos con fechas consecutivas.

¿Cómo se mantienen las fechas como se muestra debajo del formato o en el formato que envió en el archivo PBIX. Este punto es vital para que la medida funcione.

NombreFechaEstado
Fred2020.08.06día festivo
Fred2020.08.07día festivo
Fred2020.09.24día festivo
Fred2020.09.25día festivo
Ben2020.08.06día festivo
Ben2020.08.07día festivo


________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

YoutubeLinkedin



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy

Lo siento mucho, que no expliqué los datos en detalle.

Los datos sin procesar que estoy utilizando es una tabla con fechas consecutivas del año 2020 de muchos empleados diferentes. En la muestra que compartí en mi pregunta, filtré los datos a status , vacaciones para los empleados Fred y Ben.

¡Gracias y lo siento!

@bbruegge

Está bien 🙂

He creado algunos datos de origen en función de sus entradas y he realizado el resumen esperado mediante Power Query. Puede seguir los mismos pasos para incorporarlo al modelo.

Puede descargar el archivo: HERE



Fowmy_0-1596655282442.png

________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

YoutubeLinkedin


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.