Forum Discussion

Pikachu-Power's avatar
Pikachu-Power
Impactful Individual
3 years ago
Solved

BLANK fields after left join doesnt exist

Hello all,

 

in SQL i can simply do following query

 

SELECT * FROM Table1 A

LEFT JOIN (SELECT * FROM Table2 WHERE origin = 'ANALYSE') B

ON A.PK1 = B.PK2

WHERE B.PK2 IS NULL

 

In DAX:

Measure1 =
CALCULATE(DISTINCTCOUNT(Table1[PK1]),
                    Table2[origin] = "ANALYSE",
                    Table2[PK2] = BLANK())
 
doenst work because these BLANK() fields doenst exist. Table1 <--> Table2 filters both sides. Does someone see where the mistake is?
 
When I say not equal BLANK() it works and I get the right values: 
 
Measure2 =
CALCULATE(DISTINCTCOUNT(Table1[PK1]),
                    Table2[origin] = "ANALYSE",
                    Table2[PK2] <> BLANK())
 
Must be something simple that i oversee.
 
Many thanks.
 

  

  • I found a way using NATURALLEFTOUTERJOIN(Table1, Table2) and work on that with a measure. A simple relationship seems not to generate a LEFT JOIN behaviour like in SQL. Or does someone knows a way to do it without creating a new NATURALLEFTOUTERJOIN Table?

1 Reply

  • Pikachu-Power's avatar
    Pikachu-Power
    Impactful Individual

    I found a way using NATURALLEFTOUTERJOIN(Table1, Table2) and work on that with a measure. A simple relationship seems not to generate a LEFT JOIN behaviour like in SQL. Or does someone knows a way to do it without creating a new NATURALLEFTOUTERJOIN Table?