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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Medida calculada kpi

Hice esta pregunta antes, pero no lo expliqué correctamente.
así que tengo una tabla ( "TABLE 1") que tiene 4 columnas, quería crear un kpi usando Línea y gráfico de columnas agrupadas.

el cuadro contiene el objetivo de diferentes SBU para diferentes meses del año 2020.

send2.PNG

He creado otra tabla con los mismos nombres de columna, pero el SBU está vacío junto con el destino. (TABLA 2)
send1.PNG

Por lo tanto, en mi línea y gráfico de columnas agrupadas cuando no se selecciona ningún SBU debe mostrar los valores de la Tabla 2 y cuando se selecciona SBU debe mostrar el valor máximo de ese SBU en particular durante todos los meses.
send3.png

pero no sé cómo crear una medida para este problema en particular. En el punto de vista anterior cuando no se selecciona SBU se supone que muestra 94.40 % para el mes de enero de TABLE 2 , en lugar de que está mostrando 94.20% porque está tomando el promedio de todo SBU para el mes enero de TABLE 1

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hola @9192gks ,

Lo siento me temo que no he cogido su punto, ¿podría pls mostrarme su archivo .pbix, y aconsejarme su salida esperada?

Elimine los datos si son confidenciales.

Saludos
Kelly
¿Respondí a tu pregunta? ¡Marca mi puesto como solución!
v-alq-msft
Community Support
Community Support

Allí, @9192gks

En función de su descripción, he creado datos para reproducir su escenario.

pestaña:

g1.png

mesa:

g2.png

Puede crear dos medidas como se indica a continuación.

Target measure = 
var _month = SELECTEDVALUE('Table'[Month].[Month])
var _sbu = SELECTEDVALUE(Tab[SBU])
return
IF(
    NOT(ISFILTERED(Tab[SBU])),
    CALCULATE(
        SUM('Table'[Target]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Month].[Month] = _month
        )
    ),
    IF(
        HASONEVALUE(Tab[SBU]),
        CALCULATE(
            MAX(Tab[Target]),
            FILTER(
                ALLSELECTED(Tab),
                Tab[SBU] = _sbu&&
                Tab[Month].[Month] = _month
            )
        )
    )
)

KP measure = 
var _month = SELECTEDVALUE('Table'[Month].[Month])
var _sbu = SELECTEDVALUE(Tab[SBU])
return
IF(
    NOT(ISFILTERED(Tab[SBU])),
    CALCULATE(
        SUM('Table'[KP]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Month].[Month] = _month
        )
    ),
    IF(
        HASONEVALUE(Tab[SBU]),
        CALCULATE(
            MAX(Tab[KP]),
            FILTER(
                ALLSELECTED(Tab),
                Tab[SBU] = _sbu&&
                Tab[Month].[Month] = _month
            )
        )
    )
)

resultado:

g3.png

g4.png

Saludos

Allan

Si este post ayuda,entonces por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

amitchandak
Super User
Super User

@9192gks , que ha utilizado se filtra o tiene un valor

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

O

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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