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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Syndicate_Admin
Administrator
Administrator

¿Cómo calculamos los rangos de las filas de la tabla dinámicamente con ALLSELECTED?

Hola

Tengo un modelo llamado "DAS Performance", que presenta KPIs para cada periodo (año-mes) y cada empleado.

Para cada período y rol del empleado, creé una columna calculada que clasifica su rendimiento en comparación con todos los empleados en ese período.

Fíjate en las columnas marcadas en amarillo, son importantes:

haimh_0-1736593109567.png

El código para el rango calculado es :

RANK_MONTHLY_CALLS = 
IF(
    'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS] > 0 && 
    'DAS Performance'[GLOBAL_ROLE_CODE] = "Sales Representative",
    RANKX(
        FILTER(
            ALL('DAS Performance'),  -- This will consider only the filtered employees
            'DAS Performance'[MONTH_CALANDER_ID] = EARLIER('DAS Performance'[MONTH_CALANDER_ID]) &&  -- Filter by the same month
            'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS] > 0 &&  -- Only include employees with total calls > 0
            'DAS Performance'[GLOBAL_ROLE_CODE] = "Sales Representative"  -- Only for Sales Representatives
        ),
        'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS],  -- Rank based on the total calls
        ,
        DESC,  -- Sort in descending order (highest calls get rank 1)
        DENSE  -- Use dense ranking (no gaps in ranks)
    ),
    BLANK()  -- Return blank if conditions are not met
)

La columna funciona muy bien y dependo de esta columna en otras medidas.

El problema comienza cuando empiezo a usar segmentaciones de equipo / DAS (DAS = Empleado)

Si filtro el objeto visual por segmentación con un equipo específico, por ejemplo, todos los equipos siguen calculando la columna de clasificación.

Traté de pensar en cómo resolver esto con ALLSELECTED, pero me enfrenté a 2 problemas:

1) Trabajo con el nivel de fila, por lo tanto, no hay función CALCULATE en mi rango.

2) Sé que necesito una función ALLSELECTED, pero requiere CALCULATE en una medida, no en una columna calculada.

Este código, por supuesto, no funcionó:

RANK_MONTHLY_CALLS_MEASURE = 
IF(
    'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS] > 0 && 
    'DAS Performance'[GLOBAL_ROLE_CODE] = "Sales Representative",
    RANKX(
        FILTER(
            ALLSELECTED('DAS Performance'),  -- This ensures we only rank based on the current filter context (like selected employees)
            'DAS Performance'[MONTH_CALANDER_ID] = MAX('DAS Performance'[MONTH_CALANDER_ID]) &&  -- Ensure ranking is done by month
            'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS] > 0 &&  -- Only employees with positive calls
            'DAS Performance'[GLOBAL_ROLE_CODE] = "Sales Representative"  -- Ensure ranking is only for Sales Representatives
        ),
        'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS],  -- Ranking based on total calls
        ,
        DESC,  -- Highest calls get rank 1
        DENSE  -- Use dense ranking (no gaps in ranks)
    ),
    BLANK()  -- Return blank for non-representatives or zero calls
)

¿Cómo resolver este problema, entonces, si me baso en una tabla estática (modelo)

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

¡Muchas gracias! ¡Trabajado!

Hola, @haimh

Si funciona, entonces acepta la respuesta como una solución, ayuda a otros a encontrar la solución.

Syndicate_Admin
Administrator
Administrator

Hola, @haimh

No puede calcular el cálculo dinámico en la columna, en la columna una vez que ocurre la lógica / cálculo, no se puede modificar como selección de segmentación, por lo que debe ir con Medir.

RANK_MONTHLY_CALLS_measure =
VAR curr_MONTH_CALANDER_ID =
    SELECTEDVALUE ( 'DAS Performance'[MONTH_CALANDER_ID] )
RETURN
    IF (
        'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS] > 0
            && 'DAS Performance'[GLOBAL_ROLE_CODE] = "Sales Representative",
        RANKX (
            FILTER (
                ALLSELECTED ( 'DAS Performance' ),
                -- This will consider only the filtered employees
                'DAS Performance'[MONTH_CALANDER_ID] = curr_MONTH_CALANDER_ID
                    && -- Filter by the same month
                'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS] > 0
                    && -- Only include employees with total calls > 0
                'DAS Performance'[GLOBAL_ROLE_CODE] = "Sales Representative" -- Only for Sales Representatives
            ),
            CALCULATE ( SUM ( 'DAS Performance'[TOTAL_F2F_VIDEO_MONTHLY_CALLS] ) ),
            ,
            DESC,
            -- Sort in descending order (highest calls get rank 1)
            DENSE -- Use dense ranking (no gaps in ranks)
        ),
        BLANK () -- Return blank if conditions are not met
    )

Saludos
Dangar

Si esta publicación ayuda, considere Acéptalo como la solución para ayudar a los demás miembros a encontrarlo más rápidamente.



Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.