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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Syndicate_Admin
Administrator
Administrator

Necesito ayuda con una medida de conteo de días

Hola, tengo 2 perreras de alojamiento para perros y quiero saber el recuento de días entre el final anterior del perro y el comienzo del nuevo para cada habitación.

Por ejemplo, la diferencia de días entre Perro1 y Perro2 en abril 2024 A1 es de 2 días.

No tengo la columna Days_to_Fill en mis datos de origen.

UbicaciónCuartoDog_NumberStart_DateEnd_DateDays_to_Fill
MánchesterA1101/04/202410/04/20242
MánchesterA1213/04/202418/04/20247
MánchesterA1326/04/202428/04/20245
MánchesterA1403/05/202415/05/2024
NewcastleB1501/07/202412/07/20244
NewcastleB1617/07/202423/07/202415
NewcastleB1708/08/202418/08/20242
NewcastleB1821/08/202425/08/2024

Gracias

7 REPLIES 7
Syndicate_Admin
Administrator
Administrator

@RichOB

DAX para una columna calculada:

Days_to_Fill =
VAR CurrentStart = 'Table'[Start_Date]
VAR CurrentRoom = 'Table'[Room]
VAR CurrentLocation = 'Table'[Location]
VAR PreviousEnd =
MAXX(
FILTER(
'Table',
'Table'[Room] = CurrentRoom &&
'Table'[Location] = CurrentLocation &&
'Table'[End_Date] < CurrentStart
),
'Table'[End_Date]
)
RETURN
IF(
NOT ISBLANK(PreviousEnd),
DATEDIFF(PreviousEnd, CurrentStart, DAY),
BLANK()
)

💌 Si esto ayudó, ¡una marca de Kudos 👍 o Solution sería genial! 🎉
Bien
Kedar
Conéctate en LinkedIn

Syndicate_Admin
Administrator
Administrator

Estoy bastante confundido

danextian_0-1733912058837.png

Fila 1: Del 10 al 13 de abril = 3 días

Fila 2 : 18 de abril al 26 de abril = 8 días

Estas deberían ser las diferencias en días

Ubicación Cuarto Dog_Number Start_Date End_Date Days_to_Fill diferencia
Mánchester A1 1 01/04/2024 10/04/2024 2 3
Mánchester A1 2 13/04/2024 18/04/2024 7 8
Mánchester A1 3 26/04/2024 28/04/2024 5 5
Mánchester A1 4 03/05/2024 15/05/2024
Newcastle B1 5 01/07/2024 12/07/2024 4 5
Newcastle B1 6 17/07/2024 23/07/2024 15 16
Newcastle B1 7 08/08/2024 18/08/2024 2 3
Newcastle B1 8 21/08/2024 25/08/2024

Hola @danextian gracias por tu respuesta. ¿Qué medida usaste para conseguir eso, por favor?

Gracias

Es una columna calculada

Difference = 
VAR NextStart =
    CALCULATE (
        MIN ( 'Table'[Start_Date] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Room] = EARLIER ( 'Table'[Room] )
                && 'Table'[Start_Date] > EARLIER ( 'Table'[Start_Date] )
        )
    )
RETURN
    DATEDIFF ( 'Table'[End_Date], NextStart, DAY )

danextian_0-1733913161338.png

Esto funcionó perfectamente, ¡gracias!

Syndicate_Admin
Administrator
Administrator

Hola @RichOB ,
Por favor, pruebe a continuación DAX :

Days_to_Fill_Calculation =
VAR _CheckRoom = 'MesaEjemplo'[Sala]
VAR _CheckLocation = 'ExampleTable'[Ubicación]
VAR _CheckStartDate = 'TablaEjemplo'[Start_Date]
VAR _PrevEndDate =
CALCULAR(
MÁXIMO('ExampleTable'[End_Date]),
FILTRO(
'Tabla de ejemplo',
'ExampleTable'[Ubicación] = _CheckLocation &&
'ExampleTable'[Habitación] = _CheckRoom &&
'ExampleTable'[End_Date] < _CheckStartDate
)
)
DEVOLUCIÓN
SI(
ISBLANK(_PrevEndDate),
ESPACIO EN BLANCO(),
DATEDIFF(_PrevEndDate, _CheckStartDate, DÍA) -1
)
Salida:
WhatsApp Image 2024-12-11 at 15.31.46.jpeg
Puede ajustar la fórmula (con o sin -1)
Gracias
Ankita

Hola @AnkitaaMishra muchas gracias por tu ayuda. Tengo un error DAX de "No se puede convertir el valor 'Manchester' de tipo Texto a tipo Verdadero/Falso". ¿Sabes cómo resolvería esto, por favor?


Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Top Kudoed Authors