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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

3 Month Rolling Averages - How to exclude the days with no sales

Hi All 

 

How do I modify this formula so that we're only averaging over days that have sales. 

 

Average Sales 3 Month Rolling %:=
AVERAGEX(
DATESINPERIOD( 'Primary Date Table'[Date] , LASTDATE( 'Primary Date Table'[Date] ) , -3, MONTH ) , [Sales] )

 

Thanks

6 REPLIES 6
lbendlin
Super User
Super User

what's your rationale for doing that? Isn't that skewing the true performance numbers? What if it was a regular day but without sales?

Anonymous
Not applicable

Hi 

I'm actually not using it for sales. I used Sales as a simpler way of explain it as most are familiar with it.

I'm calculating to exclude non-productive days. The average number of batches calculated over a 3 month period is being diluted and brought down by non-productive days (i.e the weekend). Sometimes we produce on weekends but if we took 90 days to calculate it for example, and everyday was productive, then it would make sense (the result might be an average of 85% because it's being diluted. But if we're dividing total no. of 'batches' and dividing it by the no. of productive days, say 90-12 (sundays) = 78, then the result would be higher, such as 92% (est) for example.

Use an external dates table where you can manually mark the days that had no batches. Then use that flag in your filters.

Anonymous
Not applicable

Hi, doesn't work:

Average Right First Time 3 Month Rolling %:=
VAR RFT = 
CALCULATE (
    [Right First Time %],
    FILTER('Primary Date Table','Primary Date Table'[Batches (RFT)]>0)
)
RETURN

AVERAGEX( DATEADD('Primary Date Table'[Date],-3,MONTH)
    		,RFT)

 It's not going back -3 months.

AntrikshSharma
Super User
Super User

Try something like this:

Measure =
AVERAGEX (
    FILTER (
        DATESINPERIOD ( Dates[Date], LASTDATE ( Dates[Date] ), -3, MONTH ),
        [Total Sales] > 0
    ),
    [Total Sales]
)
Anonymous
Not applicable

@AntrikshSharma   Hi, thank you for your reply. Sorry, I used sales as a decent example for the same formula but there's been no change when I apply to batches. Basically, when we have zero batches, I don't want to include that day in the 3 month calculation.

 

 

Average Right First Time 3 Month Rolling %:=
VAR BATCHES = [No. of Batches (RFT) Fail] + [No. of Batches (RFT) Pass]
RETURN
AVERAGEX(
FILTER(
DATESINPERIOD( 'Primary Date Table'[Date] , LASTDATE( 'Primary Date Table'[Date] ) , -3, MONTH ) , 
BATCHES >0 
),
[Right First Time %]
)

 

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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