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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
Anonymous
Not applicable

How to join two tables in direct query

Hello,

I have two tables: The first tables shows my orders and products which were ordered with a quantity and the second table shows all my available products without quantity field. 

So I want to calculate based on a specific date which products were ordered and which not. 

Problem: How can I merge a table with quantity and the table without quantity. All products without quantity should get the value zero.

I can do that with an join using import modus but how to do the merge in direct query? Just need some ideas 🙂

 

Thank you in advance. Best regards.

 

filterorders.png

 

1 ACCEPTED SOLUTION

Try this:

VAR __Table =
NATURALINNERJOIN(
'Products',
SELECTCOLUMNS(
'Orders',
"SKU",[SKU],
"Quantity",[Quantity]
)
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

I am assuming product here is product dimension, Same way you have date dimension,

When you create sum of qty measure add +0

 

Qty Total = Sum(Table[Qty]) +0

 

Also, explore this option

ShowItemwithoutdata.JPG

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

You can't merge in Direct Query, you would need to edit the source system.

 

You could theoretically merge them in DAX using things like NATURALINNERJOIN, etc. but that will be part of a measure calculation.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

newtable.png

 

@Greg_Deckler  Thank you for your fast reply. So I tried to do a join but I get the error message "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."  On the picture I tried to describe what I want to create but is this even possible since the tables have different columns?

Hi,

Try this

  1. Create a relationship from the SKU field of Table1 to the SKU field of the Products Table
  2. To your visual, drag SKU and Product from the Products Table
  3. Write this measure: Total Quantity = SUM(Table1[Quantity])+0

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Try this:

VAR __Table =
NATURALINNERJOIN(
'Products',
SELECTCOLUMNS(
'Orders',
"SKU",[SKU],
"Quantity",[Quantity]
)
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Can't you just submit your sql with this join ?

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.