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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ryanjparks
Helper I
Helper I

Active Customer Count - Last 12 Months, Per Month

Hi everyone,

 

I'm thinking this should be pretty easy, but I'm having a hard time figuring out where I'm going wrong.

 

I am attempting to get an active customer count on a monthly basis (Active means any Customer who has purchased something in the last 12 months)

 

I need it to be like the following:

 

January 2023 = Distinct Count of Customers who bought between 2/1/22 - 1/31/23

February 2023 = Distinct Count of Customers who bought between 3/1/22 - 2/28/23

March 2023 = Distinct Count of Customers who bought between 4/1/22 - 3/31/23

And so on....

 

I have a Sales table with the Customer ID and the Sales Date. Additionally, I have a Calendar Table with just a date for each day.

 

I currently have a measure that has the following:

 

# Active Customers Rolling 12 Mo =
    CALCULATE(
        DISTINCTCOUNTNOBLANK(Sales[CustomerID]),
        DATESBETWEEN(Calendar[Date],EOMONTH(TODAY(),-12),EOMONTH(TODAY(),-1)
        )
    )
 
I've placed this measure in a Matrix that has a Bin of Months on Sales[InvoiceDate] for the Columns (each column is a different month). The measure was placed in the Values box. The result is giving me a unique count of customers who have purchased for that given month, but the amount but is not adding up the total for the annual distinct count for the 12 month period I need.
 
Where am I going wrong?
 
Thanks for any help...

 

1 ACCEPTED SOLUTION
ryanjparks
Helper I
Helper I

I was able to figure it out. This was the measure that got it to work:

 

# Active Customers FILTERED =
var MaxDate = MAX( Calendar[Date] )
return
    CALCULATE(
        DISTINCTCOUNTNOBLANK( Sales[CustomerID] ),
        FILTER(
            ALL ( Calendar ),
            AND( Calendar[Date] <= MaxDate, Calendar[Date] >= MaxDate - 365)
        )
    )

View solution in original post

2 REPLIES 2
ryanjparks
Helper I
Helper I

I was able to figure it out. This was the measure that got it to work:

 

# Active Customers FILTERED =
var MaxDate = MAX( Calendar[Date] )
return
    CALCULATE(
        DISTINCTCOUNTNOBLANK( Sales[CustomerID] ),
        FILTER(
            ALL ( Calendar ),
            AND( Calendar[Date] <= MaxDate, Calendar[Date] >= MaxDate - 365)
        )
    )
ryanjparks
Helper I
Helper I

Any ideas, anyone?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.