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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
yodha
Helper IV
Helper IV

¿Cómo escribir una medida usando dos tablas?

Hola, tenemos dos tablas en pbix, "Table1" y "Table2".

¿puede alguien ayudarme a escribir una "Medida" para este requisito? que pueden reemplazar los valores de la tabla 1 por la tabla 2 (no hay relaton entre tablas).

Gracias de antemano.

4 REPLIES 4
Icey
Community Support
Community Support

Hola @yodha ,

Por favor, compruebe:

1. Intente reemplazar el valor en el editor de Power Query.

= Table.ReplaceValue(#"Changed Type",each [Value], each if [Group]=false and [Type] = false and [#"Sub-type"]=false then (let Name_  = [Name] in Table.SelectRows(#"Table 2", each [Name] = Name_ and [Type] = "new")){0}[Value] else [Value],Replacer.ReplaceValue,{"Value"})

replace.PNG

2. O bien, puede crear una columna calculada o una medida en Power BI Desktop.

Column = 
IF (
    'Table 1'[Group] && 'Table 1'[Type]
        && 'Table 1'[Sub-type],
    'Table 1'[Value],
    CALCULATE (
        SUM ( 'Table 2'[Value] ),
        FILTER (
            'Table 2',
            'Table 2'[Name] = 'Table 1'[Name]
                && 'Table 2'[Type] = "new"
        )
    )
)

column.PNG

Measure = 
IF (
    SELECTEDVALUE ( 'Table 1'[Group] ) && SELECTEDVALUE ( 'Table 1'[Type] )
        && SELECTEDVALUE ( 'Table 1'[Sub-type] ),
    SUM ( 'Table 1'[Value] ),
    CALCULATE (
        SUM ( 'Table 2'[Value] ),
        FILTER (
            'Table 2',
            'Table 2'[Name] = SELECTEDVALUE ( 'Table 1'[Name] )
                && 'Table 2'[Type] = "new"
        )
    )
)

measure.PNG

BTW, archivo .pbix adjunto.

Saludos

Icey

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

mwegener
Most Valuable Professional
Most Valuable Professional

Hola @yodha ,

¿Por qué no usa Power Query?

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


@mwegener Sí, Powerquery también funciona, pero soy nuevo en Power BI y no sé cómo obtener el resultado esperado mediante la consulta de energía. ¡Gracias!

mwegener
Most Valuable Professional
Most Valuable Professional

Hola @yodha ,

Iría paso a paso.

1. Genere columnas en la tabla 2 que necesita vincular a la tabla 1. (Columnas condicionales)

2. Combine las tablas sobre estas columnas.

3. Busque el valor deseado utilizando una columna condicional.

Eche un vistazo al PBIX adjunto.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors