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
matgf
Regular Visitor

SQL query to DAX in Power BI

I have the following SQL Query:

 

SELECT * FROM [table1]

INNER JOIN (SELECT [table2].table1_id, [table4].table4_id, count(*)

FROM [table2]

INNER JOIN [table3] ON [table2].table3_id = [table3].table3_id

INNER JOIN [table4] ON [table4].table4_id = [table3].table4_id

GROUP BY [table2].table1_id) as <table5> ON [table1].table1_id = <table5>.table1_id

 

I need to do the same thing that does this but translated to DAX in order to use it in Power BI,

it would be great if i can use it in a measure, but i tried a few things that didn't work, so if it is a measure, calculated column or anything else would be nice. 

I'm a little lost with with this. Any Ideas? Thank you very much!

3 REPLIES 3
Greg_Deckler
Super User
Super User

NATURALINNERJOIN is the DAX join function and you can use SUMMARIZE for grouping.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I'm using :

Measure = CALCULATE(SUMMARIZE((NATURALINNERJOIN(<table2>;NATURALINNERJOIN(<table3>;<table4>)));"qty";count(<table2>[table1_id])))

But I Can't make it work. 

This is my relationship model.

sample.png

Hi @matgf,

 

SUMMARIZE function will return table, you can't direct use it in measure.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.