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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.