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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hnguyen76
Resolver II
Resolver II

DAX LeftouterJoin No Relationship

Hi All.

I'm attempting to create an attribute table from two fact tables in DAX. I'm fully aware that this is far easier and better to do in PowerQuery except that I'm using a database that has slow performance factor and the query takes forever to evaluate (even though I'm only pulling in a small amount of data). As an alternative I'd like to built this attribute table within DAX.


I want to pull just the distinct attributes from both fact tables so I can explode that within a table visual. These two facts are:

FACT_1

Ticket_IDCountryAmountSoldToSalesTypeYearMonthDateID.Key
1US100Party1Sales Order2020011-Jan-201^202001
2US102Party1Sales Order2020011-Jan-202^202001
3CAD104Party2Sales Order2020011-Jan-203^202001
4CAD500Party3Sales Order2020011-Jan-204^202001
5US5410Party1Sales Order2020011-Jan-205^202001
6CAD20Party4Sales Order2020011-Jan-206^202001
7CAD80Party3Sales Order2020011-Jan-207^202001
2US20Party1Sales Order2020011-Jan-202^202001
5US5400Party1Credit2020011-Jan-205^202001
5US400Party1Sales Order2020011-Jan-205^202001

 

FACT_2

Ticket_IDAmountApprovedCustomerYearMonthDateID.Key
11001Customer 1 Name2020011-Jan-201^202001
21020Customer 1 Name2020011-Jan-202^202001
31041Customer 2 Name2020011-Jan-203^202001
45000Customer 3 Name2020011-Jan-204^202001
554001Customer 1 Name2020011-Jan-205^202001
5101Customer 1 Name2020011-Jan-205^202001

 

Pretty common scenario.  If this is done in PowerQuery, I'd LEFTOUTERJOIN the FACT_1 ID.KEY to FACT_2 ID.KEY and return the distinct table values. This image result below is what I want:
sample_result_table.png

As such, when I add this with my bridge table I'm retrieving the values I want:
sample_result_visual.png

So my attempt at DAX does not yield the expected result:
LEFT_OUTER.png
LEFT_OUTER_TBL.png

 

Any ideas on how to proceed?

1 ACCEPTED SOLUTION

@v-juanli-msft ,
Thanks for the reply. Unfortunately I was looking for a route that did not consider using any relationships (active or inactive) while actively avoiding M-2-M. Considering performance vs data model size I opted with my original solution to use PowerQuery 

View solution in original post

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @hnguyen76 

two ways to get expected result as you provided:

1. create relationships

Capture2.JPGCapture3.JPGCapture4.JPG

2. create inactive relationships(inactive relationships won't filter tables)

Create calcualted columns

amount2 = CALCULATE(SUM(Table2[Amount]),USERELATIONSHIP(Table1[ID.Key],Table2[ID.Key]))

customer = LOOKUPVALUE(Table2[Customer],Table2[ID.Key],Table1[ID.Key])

Capture5.JPGCapture6.JPGCapture7.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-juanli-msft ,
Thanks for the reply. Unfortunately I was looking for a route that did not consider using any relationships (active or inactive) while actively avoiding M-2-M. Considering performance vs data model size I opted with my original solution to use PowerQuery 

amitchandak
Super User
Super User

You can use a cross join in Dax but it will make things slow. You can use it inside the filter to have your condition.

Also, use selectcolumns to rename and select columns as this will not Allow same name column.

 

Use summarize of top of it.

@amitchandak ,

CROSSJOIN is definitely out of the question. I tried it with my dataset yesterday and it returned me 2 billion rows and took about 20 minutes to evaluate. 

I think the option you planning to use of power query is better. What you actally want to achieve using merge

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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