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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
andrewmvu41
New Member

Help creating rolling average of a distinct counted column

PBI Gods... I am looking to do a rolling average of a distinct counted column. I got as far as the following DAX: Rolling Avg = CALCULATE(DISTINCTCOUNT(Incidents[Incident #]), DATESINPERIOD('Date Calendar'[Date], MAX('Date Calendar'[Date]), -2, MONTH), FILTER( BU, BU = "Sales"))

 

it doesn't do exactly what I want. It is giving me the rolling sum of the values instead of average. I did try the following DAX below also, but it also didn't give me what I needed. 

L&T Rolling Avg 2 =
AVERAGEX(DATESYTD('Date Calendar'[Date]), CALCULATE(DISTINCTCOUNT(Incidents[RecInj]), DATESBETWEEN('Date Calendar'[Date], MAX('Date Calendar'[Date]) - 364MAX('Date Calendar'[Date])),FILTER(BU, BU[tbl] = "Sales")))
 
The table looks something like below:
4/1/20232
3/1/20231
2/1/20231
12/1/20221
11/1/20221
10/1/20222
8/1/20222
7/1/20223
5/1/20221
4/1/20225
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Write a measure that is just the distinct incident count.

 

Incident Count = DISTINCTCOUNT ( Incidents[Incident #] )

 

Then you can use that in a your rolling average measure.  You just have to find the hightest date you are lookin at and then we can manipulate the date range being used.

 

Rolling 2 Avg = 
VAR _MaxDate = MAX ( DATES[Date] )
RETURN
AVERAGEX ( 
    CALCULATETABLE ( 
        VALUES ( 'Date Calendar'[Month Year] ), 
        DATESINPERIOD( 'Date Calendar'[Date], _MaxDate, -2, MONTH )
    ),
    [Incident Count]
)

 

This will give us the average of the current month and previous month amounts for each month.

 

jdbuchanan71_0-1684166647081.png

 

View solution in original post

1 REPLY 1
jdbuchanan71
Super User
Super User

Write a measure that is just the distinct incident count.

 

Incident Count = DISTINCTCOUNT ( Incidents[Incident #] )

 

Then you can use that in a your rolling average measure.  You just have to find the hightest date you are lookin at and then we can manipulate the date range being used.

 

Rolling 2 Avg = 
VAR _MaxDate = MAX ( DATES[Date] )
RETURN
AVERAGEX ( 
    CALCULATETABLE ( 
        VALUES ( 'Date Calendar'[Month Year] ), 
        DATESINPERIOD( 'Date Calendar'[Date], _MaxDate, -2, MONTH )
    ),
    [Incident Count]
)

 

This will give us the average of the current month and previous month amounts for each month.

 

jdbuchanan71_0-1684166647081.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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