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
Syndicate_Admin
Administrator
Administrator

Filtro anidado que cuenta las filas con una condición

Hola, necesito crear una medida dax para saber cuántas personas informan a una persona, en una estructura org típica.

Mi tabla de datos de la organización tiene todos los empleados junto con su jefe de equipo, gerente y director como columnas separadas.

Si la persona es un gerente, no hay un líder de equipo para él. Pero hay un director en la cima.

Necesito saber cuántas personas debajo de cada persona. Ver datos de muestra en la foto de abajo

Paso bastante tiempo, probando con filtros/cuenta, su no llevándome anywhere. Agradezco enormemente su ayuda.

org3.jpg

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Pude hacer que funcionara con el siguiente script

Team Count = 
var currentName = Sheet1[Employee Name]

var cnt = 
SWITCH(Sheet1[Position],
            "TL",
                    calculate(
                            COUNT(Sheet1[Employee Name]),
                            FILTER(Sheet1, Sheet1[Team Lead]=currentName)
                    ),
            "M",
                    calculate(
                            COUNT(Sheet1[Employee Name]),
                            FILTER(Sheet1, Sheet1[Manager]=currentName)
                    ),
            "D",
                    calculate(
                            COUNT(Sheet1[Employee Name]),
                            FILTER(Sheet1, Sheet1[Director]=currentName)
                    ),
            0
)
return cnt

solution.jpg

View solution in original post

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

Pude hacer que funcionara con el siguiente script

Team Count = 
var currentName = Sheet1[Employee Name]

var cnt = 
SWITCH(Sheet1[Position],
            "TL",
                    calculate(
                            COUNT(Sheet1[Employee Name]),
                            FILTER(Sheet1, Sheet1[Team Lead]=currentName)
                    ),
            "M",
                    calculate(
                            COUNT(Sheet1[Employee Name]),
                            FILTER(Sheet1, Sheet1[Manager]=currentName)
                    ),
            "D",
                    calculate(
                            COUNT(Sheet1[Employee Name]),
                            FILTER(Sheet1, Sheet1[Director]=currentName)
                    ),
            0
)
return cnt

solution.jpg

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.