Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
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 inicio | Fecha de finalización | Índice |
| 1 | 1-1-2025 | 8-1-2025 | 1 |
| 1 | 9-1-2025 | 16-1-2025 | 1 |
| 1 | 1-2-2025 | 8-2-2025 | 2 |
| 1 | 1-3-2025 | 2-3-2025 | 3 |
| 2 | 4-2-2025 | 6-2-2025 | 1 |
| 2 | 3-3-2025 | 4-3-2025 | 2 |
| 2 | 5-3-2025 | 6-3-2025 | 2 |
@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:
Gracias por la fórmula, pero tengo algunos problemas, vea a continuación el resultado con estas fórmulas.
@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
| Empleado | Fecha de inicio | Fecha de finalización | Orden | Índice | Esperado |
| 1 | 5-12-2022 | 13-3-2023 | 13-3-2023 | 1 | 1 |
| 1 | 14-3-2023 | 19-3-2023 | 13-3-2023 | 1 | 1 |
| 1 | 20-3-2023 | 10-4-2023 | 19-3-2023 | 2 | 1 |
| 1 | 11-4-2023 | 25-6-2023 | 10-4-2023 | 3 | 1 |
| 1 | 26-6-2023 | 17-1-2024 | 25-6-2023 | 4 | 1 |
| 1 | 18-1-2024 | 31-1-2024 | 17-1-2024 | 5 | 1 |
| 1 | 1-2-2024 | 6-2-2024 | 31-1-2024 | 6 | 1 |
| 1 | 7-2-2024 | 1-3-2024 | 6-2-2024 | 7 | 1 |
| 1 | 1-7-2024 | 31-7-2024 | 31-7-2024 | 8 | 2 |
| 1 | 1-8-2024 | 15-9-2024 | 31-7-2024 | 8 | 2 |
| 1 | 16-9-2024 | 29-10-2024 | 15-9-2024 | 9 | 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 |
| 3 | 1-4-2024 | 4-4-2024 | 4-4-2024 | 1 | 1 |
| 3 | 5-4-2024 | 9-4-2024 | 4-4-2024 | 1 | 1 |
@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
Gracias por toda su ayuda.
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)
)
)
)
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.