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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. 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
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

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

Top Solution Authors
Top Kudoed Authors