Nelson Gomes Matias
Nelson Gomes Matias

Reputation: 1997

LEFT JOIN with DAX

I am looking for a way to do a LEFT JOIN like in SQL but with DAX. So let say that I have 2 tables A and B. B is a subset of A. so having

Table A:
  rowa  
  rowb 
  rowc 

and having

Tabel B:
rowa

I need TableC with:

A.rowa; B.rowa
A.rowb; null
A.rowc; null

How can I achieve this with DAX?

Thank you for your time!

Upvotes: 3

Views: 14594

Answers (3)

Seymour
Seymour

Reputation: 3274

please provide more context and explain what is the problem you are trying to solve.

In general, DAX works with extended table which means that it works by default with tables already denormalized according to relationships you define in the data model.

Therefore, unless of specific needs or constraints, it is best practice to define this as a relationship in the data model, and not a left join in DAX formula. Physical relationships in the data model is what makes DAX execution quick and clear.

Upvotes: 0

Jason Wang
Jason Wang

Reputation: 51

For example:

DEFINE
  VAR TABLE1=DATATABLE("L1",STRING,{{1},{2}})
  VAR TABLE2=DATATABLE("L1",STRING,{{1},{3}})
EVALUATE
  NATURALLEFTOUTERJOIN(TABLE1,ADDCOLUMNS(TABLE2,"L2",[L1]))

Upvotes: 4

Nithin
Nithin

Reputation: 1414

try this.............

NATURALINNERJOIN(<leftJoinTable>, <rightJoinTable>) 

Upvotes: 2

Related Questions