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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
SteveD2
Resolver I
Resolver I

Problem with DAX Intersect Function

I've created to measures to count and total sales for new customers. The equations look like this.

Count of Returning Customer V2 = 
Var CustomersList = VALUES(Orders[CustomerID])
Var PriorCustomers = CALCULATETABLE(VALUES(Orders[CustomerID]),
    FILTER(ALL('Date Table'), 
        'Date Table'[Date] < MIN('Date Table'[Date])))
Return
COUNTROWS(
    INTERSECT(CustomersList, PriorCustomers))

And

Returning Customer Sales V2 = 
Var CustomersList = VALUES(Orders[CustomerID])
Var PriorCustomers = CALCULATETABLE(VALUES(Orders[CustomerID]),
    FILTER(ALL('Date Table'), 
    'Date Table'[Date] < MIN('Date Table'[Date])))
Return
CALCULATE([Total Sales],
    INTERSECT(CustomersList, PriorCustomers))

They appear identical but, when I put them in a table the Sales calculation includes new customers.Intersect error.jpg

 

 Any suggestion on what I'm doing wrong?

4 REPLIES 4
SteveD2
Resolver I
Resolver I

G'day Greg,

My data source is the Northwinds database. I can attach the PBI file if that helps?

 

yes, your suggested alternative would work but, the next problem I have is I am trying dynamically categorise customers as New, Returning or Lost and will need a measure for each (?).

Anonymous
Not applicable

@SteveD2,

You can share PBIX file through online services such as OneDrive, also post expected result.

Regards,
Lydia

Greg_Deckler
Community Champion
Community Champion

No sample data so hard to troubleshoot. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

That being said, why not just change your 2nd measure to:

 

Returning Customer Sales V2 = 
IF(NOT(ISBLANK([Count of Returning Customer V2])),[Total Sales],BLANK())


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...

Greg,

My Apologies for not replying sooner but, I got busy doing other things. I'm attaching a link to a PBIX file that highlights the issue using the Intersect function. The Column headings identify those calculations that are working correctly ( and use Intersect) and the final column which is not calculating as it should (and uses intersect). I'm sure its something to do with context transition but, I can't see how its changed for that one measure.

Intersect calculation issue

 

I hope this helps.

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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