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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
pcavacas
Helper I
Helper I

Slow DAX Measure, trying to find overlapping Dates

I have the below DAX Expressions

 
Count Of Overlaps = 
var fromDate = MIN('VF Trade Spend'[From])
var toDate = MAX('VF Trade Spend'[To])

return CALCULATE(DISTINCTCOUNT('VF Trade Spend'[Contract Line #]),
    REMOVEFILTERS('VF Trade Spend'[Contract Line #], 'VF Trade Spend'[From], 'VF Trade Spend'[To]),
    FILTER('VF Trade Spend', 
        'VF Trade Spend'[From] >= fromDate 
        && 'VF Trade Spend'[From] <= toDate
        && 'VF Trade Spend'[To] >= fromDate 
        && 'VF Trade Spend'[To] <= toDate
    )
)

 

This DAX measure is working, but it is really slow (takes 30+ seconds to complete).

 

The main point of what it is trying to do is we have a table that has a contract # and start and end dates on it.  I'm trying to find a count of any contracts that have overlapping date ranges in them.

1 ACCEPTED SOLUTION
AntrikshSharma
Community Champion
Community Champion

That is an optimization problem, I had the same problem and Marco Russo from SQLBI suggested to use this construct:

SUMX( DISTINCT ( 'VF Trade Spend'[Contract Line #] ), 1 )

Please read this article here. SQLBI: Analyzing the performance of DISTINCTCOUNT

View solution in original post

1 REPLY 1
AntrikshSharma
Community Champion
Community Champion

That is an optimization problem, I had the same problem and Marco Russo from SQLBI suggested to use this construct:

SUMX( DISTINCT ( 'VF Trade Spend'[Contract Line #] ), 1 )

Please read this article here. SQLBI: Analyzing the performance of DISTINCTCOUNT

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors