Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Time intelligence measure

Hi,

 

Im trying to get the count of clients per day in the last year. I got the real number using the distinct count of "Codigo_Cliente" by "Fecha_Primer_Producto".

 

To get the last year number, Im using the following formula:

 

Last year clients =
CALCULATE(
    DISTINCTCOUNT('Clientes Hoy'[Codigo_Cliente]),
FILTER('Clientes Hoy',DATEADD('Clientes Hoy'[Fecha_Primer_Producto],-1,YEAR))
)
 
However, I dont get the right number. Can you please help me?
 
Data here:
 
Normal data
Count of Codigo_ClienteYear
59981 
11993
11994
11995
11996
61997
201998
2821999
7332000
24772001
26892002
56402003
61612004
51862005
56532006
75572007
95582008
96792009
100292010
134362011
233492012
274402013
356982014
360972015
385382016
364372017
376102018
30317

2019

 

Data with the date add formula:

YearClientes ano pasado
19982
199935
2000127
20011984
20021480
20033986
20042855
20052861
20063882
20075419
20086092
20097021
20107720
201110419
201214671
201320492
201428029
201528295
201623678
201727037
201828506
201923142
 
  • Anonymous you need to add calendar table in your model, there are many posts on how to do it. one you have this table, set relationship with your transaction table and then update your measure as below

     

    Last year clients = 
    CALCULATE(
        DISTINCTCOUNT('Clientes Hoy'[Codigo_Cliente]),
    DATEADD(Calendar[Date],-1,YEAR)
    )

1 Reply

  • Anonymous you need to add calendar table in your model, there are many posts on how to do it. one you have this table, set relationship with your transaction table and then update your measure as below

     

    Last year clients = 
    CALCULATE(
        DISTINCTCOUNT('Clientes Hoy'[Codigo_Cliente]),
    DATEADD(Calendar[Date],-1,YEAR)
    )