I need to calculate the date difference in the same column - DAX PBI

Asked

Viewed 48 times

0

I need to know how many days it takes a customer to make a new purchase, IE, what is the difference between purchase dates.

I used the logic cited here as a possible solution, but without success:

Days_diff = 
VAR StartDate = 
CALCULATE (
 LASTDATE ( 'Consumo (Financeiro)'[Data faturamento] ), 
FILTER ( 
ALLEXCEPT ( 'Consumo (Financeiro)', 'Consumo (Financeiro)'[CLIENTE_UNIFICADO]), 
'Consumo (Financeiro)'[Data faturamento] < EARLIER ( 'Consumo (Financeiro)'[Data faturamento] )
 ) 
) 
RETURN 
DATEDIFF ( StartDate, 'Consumo (Financeiro)'[Data faturamento], DAY )

This error occurs:

EARLIER/EARLIEST refers to an earlier Row context which doesn’t exist.

Someone can help me?

  • By mistake I think that this can only be done for customers with more than one purchase , >> ( (largest purchase date - minor date)/(Qtd customer purchases - 1) )

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.