cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
matgf Frequent Visitor
Frequent 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
Super User
Super User

Re: SQL query to DAX in Power BI

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


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

Highlighted
matgf Frequent Visitor
Frequent Visitor

Re: SQL query to DAX in Power BI

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

Community Support Team
Community Support Team

Re: SQL query to DAX in Power BI

Hi @matgf,

 

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

 

Regards,

Xiaoxin Sheng

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



For learning resources/Release notes, please visit: | |

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 376 members 3,475 guests
Please welcome our newest community members: