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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Community Champion
Community Champion

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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