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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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

amitchandak
Super User
Super User

@bbruegge , referirse

https://community.powerbi.com/t5/Desktop/Build-measure-or-column-to-show-a-streak-by-consecutive-dat...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors