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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Syndicate_Admin
Administrator
Administrator

Índice

Buscando la fórmula que crea el índice como en el ejemplo. Por ID de empleado, se comprueba si entre las notificaciones, por ejemplo, la primera línea de la fecha de finalización y la 2ª línea de la fecha de inicio, hay una diferencia de días, si no hay diferencia, el índice sigue siendo el mismo, si la diferencia > 1 día, entonces el índice aumenta.

Empleado Fecha de inicioFecha de finalizaciónÍndice
11-1-20258-1-20251
19-1-202516-1-20251
11-2-20258-2-20252
11-3-20252-3-20253
24-2-20256-2-20251
23-3-20254-3-20252
25-3-20256-3-20252

9 REPLIES 9
Syndicate_Admin
Administrator
Administrator

@WimHenderickx

Cree dos columnas calculadas para lograr esto.
1ª Columna:

Order = 
VAR __CurrStartDate = Table03[StartDate]
VAR __CurrEndDate = Table03[EndDate]
VAR __PrevEndDate = CALCULATE( MAX(Table03[EndDate]) , Table03[EndDate] < __CurrStartDate  , ALLEXCEPT(Table03, Table03[Employe ]) )
RETURN
   IF(ISBLANK( __PrevEndDate) , __CurrEndDate , IF( INT(__CurrStartDate - __PrevEndDate) = 1 , __PrevEndDate , __CurrEndDate ))


2ª Columna:

Index = 
ROWNUMBER( ALL(Table03[Employe ],Table03[Order]) , ORDERBY( Table03[Order] ) , PARTITIONBY( Table03[Employe ] ))


Resultado:

Fowmy_0-1739103497373.png







Gracias por la fórmula, pero tengo algunos problemas, vea a continuación el resultado con estas fórmulas.

WimHenderickx_0-1739105241316.png

@WimHenderickx

Déjame comprobarlo, pega tus datos de muestra en la respuesta en lugar de compartirlos como imagen.
Incluya también a dos o tres empleados.

Se estropea después de la segunda fila cuando no hay ningún espacio entre endDate y startdate

EmpleadoFecha de inicioFecha de finalizaciónOrdenÍndiceEsperado
15-12-202213-3-202313-3-202311
114-3-202319-3-202313-3-202311
120-3-202310-4-202319-3-202321
111-4-202325-6-202310-4-202331
126-6-202317-1-202425-6-202341
118-1-202431-1-202417-1-202451
11-2-20246-2-202431-1-202461
17-2-20241-3-20246-2-202471
11-7-202431-7-202431-7-202482
11-8-202415-9-202431-7-202482
116-9-202429-10-202415-9-202492
216-3-202320-3-202320-3-202311
216-7-202319-7-202319-7-202311
31-4-20244-4-20244-4-202411
35-4-20249-4-20244-4-202411

@WimHenderickx

¿Debería ser 1, 2

2 16-3-2023 20-3-2023 20-3-2023 1 1
2 16-7-2023 19-7-2023 19-7-2023 1 1

Sí, tienes razón

@WimHenderickx

Por favor, pruébelo ahora:

Order = 
VAR __CurrStartDate = Table03[StartDate]
VAR __PrevEndDate =
    CALCULATE (
        MAX ( Table03[EndDate] ),
        Table03[EndDate] < __CurrStartDate,
        ALLEXCEPT ( Table03, Table03[Employe ] )
    )
VAR __Result =
    IF (
        ISBLANK ( __PrevEndDate ),
        1,
        IF ( INT ( __CurrStartDate - __PrevEndDate ) <= 1, 0, 1 )
    )
RETURN
    __Result



Index = 
VAR __Emp = Table03[Employe ]
VAR __StartDate = Table03[StartDate]
VAR __Result =
    CALCULATE (
        SUM ( Table03[Order] ),
        Table03[Employe ] = __Emp,
        Table03[StartDate] <= __StartDate,
        REMOVEFILTERS ( table03 )
    )
RETURN
    __Result

Fowmy_0-1739110650491.png

Gracias por toda su ayuda.

Syndicate_Admin
Administrator
Administrator

@WimHenderickx

Pruébalo

Índice =
1 +
CALCULAR(
SUMX(
FILTRO(
SuMesa,
TuTabla[Empleado] = ANTES(TuTabla[Empleado])
&& TuTabla[FechaDeInicio] <= ANTES(TuTabla[FechaDeInicio])
),
VAR currStart = TuTabla[FechaDeInicio]
VAR prevInicio =
CALCULAR(
MAX(YourTable[StartDate]),
FILTRO(
SuMesa,
TuTabla[Empleado] = ANTES(TuTabla[Empleado])
&&YourTable[StartDate] < currStart
)
)
VAR prevEnd =
CALCULAR(
MAX(YourTable[EndDate]),
FILTRO(
SuMesa,
TuTabla[Empleado] = ANTES(TuTabla[Empleado])
&& TuTabla[FechaDeInicio] = prevInicio
)
)
DEVOLUCIÓN
SI(
ISBLANK(prevFin),
0,
IF(currStart - prevEnd > 1, 1, 0)
)
)
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors