Hi,
I have a model where I have a Customers table and an Orders Table. I want to add a new mesure in the Customers table where i want to compute the average buying cyle. So i add this DAX mesure:
BUYING_CYCLE =
AVERAGEX(ORDERS;
DATEDIFF( CALCULATE (
MAX ( 'ORDERS'[ORDER_DATE] ) ;
FILTER(ORDERS; EARLIER('ORDERS'[ORDER_DATE]) >= 'ORDERS'[ORDER_DATE] )
); 'ORDERS'[ORDER_DATE]
; DAY )
)
This works fine but it's not correct. I should add a second filter like this:
FILTER(ORDERS; EARLIER('ORDERS'[ORDER_DATE]) >= 'ORDERS'[ORDER_DATE] ) && EARLIER('ORDERS'[ID]) <> 'ORDERS'[ID] )
But if I add this second expression the query is really slow and the memory gets to 98 plus %. There aren't a lot of records in the Orders table, like 25000.
Can anybody tell me how can i understand what is happening here?
Thank you.