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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Rolling average of a measure using DISTINCTCOUNT

Hi all,

 

So I have a typical sales data table with columns containing Date, CustomerName, ProductCode, Qty, Price etc.

 

I am analysing the number of unique customers ordering from us per week, and have a measure using:

 

DistinctCustomers = DISTINCTCOUNT(CustomerName)

 

which I have plotted over time (see below) and this works fine.  

 

CustomerCount.jpg

 

However I also want to include a 13 week (91 day) rolling average to smooth out the peaks and troughs and assess the general trend. I tried the usual

 

CALCULATE(DistinctCustomers, DATESINPERIOD(Date, LASTDATE(Date), -91, DAY)

 

Divided by 13 to get the 13 week average. However the above seems to calculate the number of unique customers within the 13 week period, not the sum of the unique customers in each week. I guess I could create a measure containing 13 individual CALCULATE statements, one for each week of the rolling average, sum them and divide by 13 but I can't believe that is the most elegant DAX solution.

 

Anyone out there already have a solution to rolling average of a DISTINCTCOUNT measure? Any help or suggestions gratefully received.

 

Cheers,

 

Michael.

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

Maybe this is what you are looking for:

SUMX(
    DATESINPERIOD(Date, LASTDATE(Date), -91, DAY)
    ,[DistinctCustomers]
)
/13 

Hopefully this provides what you are looking for.

 

If not - you might consider to provide an Excel file with some sample data, upload the file to onedrive or dropbox and share the link. This provides the possiblity to make up your expected result and also avoids misunderstandings.

 

Regards,

Tom

 

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey,

 

Maybe this is what you are looking for:

SUMX(
    DATESINPERIOD(Date, LASTDATE(Date), -91, DAY)
    ,[DistinctCustomers]
)
/13 

Hopefully this provides what you are looking for.

 

If not - you might consider to provide an Excel file with some sample data, upload the file to onedrive or dropbox and share the link. This provides the possiblity to make up your expected result and also avoids misunderstandings.

 

Regards,

Tom

 

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Your a genius, many thanks Tom, that is working perfectly.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors