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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dupreem
Frequent Visitor

Recuento de empleados a lo largo del tiempo a partir de datos transaccionales

Hola

Estoy trabajando en la construcción de la funcionalidad de volumen de negocios y necesito conocer el número de empleados en un momento determinado. Los datos transaccionales que estoy usando se ven algo como esto:

Id. de empleado

Fecha del evento

Estado

1

1/1/20

Activo

2

1/1/20

Activo

3

2/1/20

Activo

1

3/1/20

Terminado

2

3/1/20

Activo

3

3/1/20

Activo

1

4/1/20

Activo

Sobre la base de los datos transaccionales anteriores, esperaría ver el número de empleados de fin de mes para cada mes a ser: Enero , 2, Febrero 3, Marzo - 2, Abr - 3.

Los empleados tendrán varias transacciones para su ID de empleado.

Cualquier ayuda es muy apreciada!

1 ACCEPTED SOLUTION

@dupreem -

Measure 14 = 
    VAR __Date = MAX([Event Date ])
    VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
    VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && ([Status]="Terminated" || [Status]="Retiree" || [Status]="Dead")),"ID",[Employee ID ]))
RETURN
    COUNTROWS(EXCEPT(__Active, __Term))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@dupreem - Ver archivo PBIX adjunto a continuación sig, Página 14

Measure 14 = 
    VAR __Date = MAX([Event Date ])
    VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
    VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Terminated"),"ID",[Employee ID ]))
RETURN
    COUNTROWS(EXCEPT(__Active, __Term))


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler ¡Muchas gracias! Si tengo varios estados "Terminado" (es decir, "Terminado, Retirado), ¿cómo actualizaría la Medida?

@dupreem -

Measure 14 = 
    VAR __Date = MAX([Event Date ])
    VAR __Active = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && [Status]="Active"),"ID",[Employee ID ]))
    VAR __Term = DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table (14)'),[Event Date ]<=__Date && ([Status]="Terminated" || [Status]="Retiree" || [Status]="Dead")),"ID",[Employee ID ]))
RETURN
    COUNTROWS(EXCEPT(__Active, __Term))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler ¡Eres genial! ¡Muchas gracias!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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