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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

DAX

Hi,

 

I want to convert this SQL query into dax for one of my calculations. I used Leftouterjoin but brings blank value. How to write the same logic in DAX.

 

Query:

select count(*) from "CB_ODS_BA_TEST"."GTM"."FRESHSALES_DEALS_ACTIVE" deal left outer join "CB_ODS_BA_TEST"."GTM"."FRESHSALES_LEADS_ACTIVE" lead on deal.deal_id=lead.deal_id where lead.deal_id is null

 

Reg,

Dhana

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Please go to Model Panel (Left hand ribbon) to do the joining among tables as coded in SQL, And then use the below DAX formula to  count rows.

 

SQL_To_DAX =
CALCULATE ( COUNTROWS ( 'Table' ), lead.deal_id = null )

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.

 

Regards,

Gaurav Raj Singh

LinkedIN : https://www.linkedin.com/in/gauravrajsingh/

Anonymous
Not applicable

Hi @Anonymous ,

 

Can't you sort of invert the where statement to "show me all Deals except if there is a Lead"?

 

Then you can use a measure like this": COUNTROWS(EXCEPT( 'Deal', 'Lead'))

 

Jan 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.