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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
powerbi2srm
Resolver II
Resolver II

CALCULAR VALORES DISTINTOS DE DOS TABLAS

Hola!

 

Quiero calcular el número de valores que no coinciden entre dos columnas de dos tablas diferentes.

En mi caso, tengo una tabla de facturas (fact_sale_invoice) y otra de ventas (fact_sale_order) relacionadas a través de una tabla intermedia (rel_sale_order_invoice). Quiero hallar cuántos valores hay distintos entre las columnas de extended_amount de ambas tablas:

pv descuadrados.PNG

 

Esto es lo que he intentado, aunque de forma fallida (soy nuevo en esto y no estoy muy seguro del uso de SELECTEDVALUE): 

 

PV_descuadrados =
IF(
    SELECTEDVALUE(fact_sale_order[sales_amount])<>SELECTEDVALUE(fact_sale_invoice[invoice_amount]),
    COUNT(fact_sale_order[sale_order_id]),
    0
)

 

 

Gracias!!

2 REPLIES 2
powerbi2srm
Resolver II
Resolver II

No se puede realizar de alguna forma sin tener que generar una tabla nueva que tenga las dos columnas que me interese? Es decir, no existe una expresión DAX que permita comparar valores de dos tablas distintas?

Mil gracias!!

Anonymous
Not applicable

Hi  @powerbi2srm ,

I created some data:

Table1:

vyangliumsft_0-1663731981543.png

Table2:

vyangliumsft_1-1663731981546.png

Intermediate tables:

vyangliumsft_2-1663731981547.png

Directly in the measure using two columns for comparison, there may be a Cartesian product, you can consider doing it in the calculated column.

Here are the steps you can follow:

1. Create calculated column.

Create calculated column pull indexes in two tables:

Table1Index =
SUMX(FILTER(ALL('Intermediate tables'),'Intermediate tables'[ID]='Table'[ID]),[Index])
Table2Index =
SUMX(FILTER(ALL('Intermediate tables'),'Intermediate tables'[ID2]='Table2'[ID2]),[Index])
Table2_amount =
SUMX(FILTER(ALL('Table2'),'Table'[Table1Index]='Table2'[Table2Index]),[Amount])
Flag =
IF(
   'Table'[Table2_amount]='Table'[Amount],1,0)
Value =
IF(
    [Flag]=1,COUNTX(FILTER(ALL('Table'),[Flag]=1),[ID]),0)

vyangliumsft_3-1663731981550.png

2. Result:

vyangliumsft_4-1663731981557.png

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.