Getting difference column in power bi

38 Views Asked by At

I want to create difference column using two tables Table 1 and Table 2 , I want to create Table 3 which is having difference of count column using DAX formula

enter image description here

2

There are 2 best solutions below

0
davidebacci On
Table3 = 
ADDCOLUMNS(
    DISTINCT(UNION(VALUES(Table1[Product]), VALUES(Table2[Product])) ),
    "@Diff", 
    VAR a = LOOKUPVALUE(Table1[Count], Table1[Product], Table1[Product])
    VAR b = LOOKUPVALUE(Table2[Count], Table2[Product], Table1[Product])
    RETURN a-b
    
    )

enter image description here

1
Tasnia Tabassum Oishee On
Table3 = 
SUMMARIZECOLUMNS(
    Table1[YourKeyColumn],
    "Count_Table1", COUNTROWS(Table1),
    "Count_Table2", CALCULATE(COUNTROWS(Table2))
    "Difference", [Count_Table1] - [Count_Table2]
)