Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hola
Estoy tratando de calcular el número total de empleados activos y el crecimiento interanual.
El desafío al que me enfrento es que mis datos no están comúnmente organizados, ya que estoy usando solo 1 columna de fecha.
Los datos se estructuran de la siguiente manera y se conectan a una tabla de dimensión de fecha denominada [DateDim]
Identificación del empleado | Estado | Fecha de inicio | Acción |
1001 | Activo | 2022-06-20 | Nueva contratación |
1001 | Activo | 2023-10-27 | Excedencia |
1001 | Activo | 2024-12-04 | Regreso al trabajo |
1001 | Terminado | 2025-01-13 | Terminación |
1001 | Activo | 2022-06-05 | Volver a contratar |
1002 | Activo | 2022-06-20 | Nueva contratación |
1003 | Activo | 2025-02-10 | Nueva contratación |
1004 | Activo | 2025-06-01 | Nueva contratación |
1005 | Activo | 2022-05-20 | Nueva contratación |
1005 | Activo | 2023-02-20 | Cambio de posición |
1005 | Terminado | 2025-05-15 | Terminación |
Gracias
@ryan_mayu Sí, debería ser un conteo acumulativo. Digamos que estoy archivando a partir de hoy, los que estuvieron activos desde 2022 hasta el presente también deben contarse como activos. Espero que tenga sentido. Gracias.
Hola @PatLam0187 ,
Esto se puede lograr con 2 medidas.
La primera medida sería calcular el número total de empleados activos y sería así:
ActiveEmployees =
VAR SelectedDate = MAX('DateDim'[Date])
VAR LatestActive =
ADDCOLUMNS(
SUMMARIZE(
'EmployeeActions',
'EmployeeActions'[EmployeeID],
"LatestActionDate",
CALCULATE(
MAX('EmployeeActions'[BeginDate]),
'EmployeeActions'[BeginDate]<=SelectedDate
)
),
"LatestActionStatus",
CALCULATE(
MAX('EmployeeActions'[Status]),
FILTER(
'EmployeeActions',
'EmployeeActions'[EmployeeID]=EARLIER('EmployeeActions'[EmployeeID])
&& 'EmployeeActions'[BeginDate]=EARLIER([LatestActionDate])
)
)
)
RETURN
COUNTROWS(
FILTER(LatestActive,[LatestActionStatus]="Active")
)
A continuación, podemos utilizar una segunda medida como la siguiente para calcular el crecimiento interanual:
ActiveEmployeesYoY =
VAR CurrentDate = MAX('DateDim'[Date])
VAR PrevYearDate = EDATE(CurrentDate,-12)
VAR CurrentValue =
CALCULATE([ActiveEmployees],'DateDim'[Date]=CurrentDate)
VAR PrevYearValue =
CALCULATE([ActiveEmployees],'DateDim'[Date]=PrevYearDate)
RETURN
DIVIDE(CurrentValue-PrevYearValue,PrevYearValue)
Si esto ayudó, márquelo como la solución para que otros también puedan beneficiarse. Y si lo encontró útil, siempre se agradecen las felicitaciones.
Gracias
Samson
Conéctate conmigo en LinkedIn (en inglés)
Echa un vistazo a mi Blog
¿Vas a asistir a la Conferencia Europea de la Comunidad Microsoft Fabric? Echa un vistazo a mi Sesión
Gracias, @SamsonTruong sin embargo, esto solo cuenta a aquellos que estaban activos hasta la fecha. También tengo que incluir a aquellos que estuvieron activos en las fechas anteriores. Digamos que alguien está activo en 2023, esa persona también debe incluirse en el conteo de hoy. Gracias de nuevo.