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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

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
 
1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@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)
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

1 REPLY 1
parry2k
Super User
Super User

@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)
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

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

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (2,849)