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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
NicoleApple
New Member

7 day moving average

I am trying to urgently calculate a 7 day moving a average but im having issues. I could do it in Excel but i want to use Power BI to present the data instead and my DAX is a little rusty as i havent used it for 4 years!

I have created a formula as follows:

7 day moving average =
CALCULATE (
SUM ( 'PCR TEsting Data'[Total Volume of Tests (Excl. work in progress or tests referred out) (No.)] ) / 7,
DATESINPERIOD (
'PCR TEsting Data'[Relevant Date],
LASTDATE ( 'PCR TEsting Data'[Relevant Date] ),
-7,
DAY
) but it is coming up with an error saying "Argument 3 in Calculate function is required. Am i missing something here? 
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I do not fully understand the DAX formula, but I think it has to have one more  )  at the end of the formula.

 

 

7 day moving average =
CALCULATE (
    SUM ( 'PCR TEsting Data'[Total Volume of Tests (Excl. work in progress or tests referred out) (No.)] ) / 7,
    DATESINPERIOD (
        'PCR TEsting Data'[Relevant Date],
        LASTDATE ( 'PCR TEsting Data'[Relevant Date] ),
        -7,
        DAY
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I do not fully understand the DAX formula, but I think it has to have one more  )  at the end of the formula.

 

 

7 day moving average =
CALCULATE (
    SUM ( 'PCR TEsting Data'[Total Volume of Tests (Excl. work in progress or tests referred out) (No.)] ) / 7,
    DATESINPERIOD (
        'PCR TEsting Data'[Relevant Date],
        LASTDATE ( 'PCR TEsting Data'[Relevant Date] ),
        -7,
        DAY
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hi @NicoleApple,

It seems like a DAX syntax issue that loses the right brackets at the end of your formula.  You can add it to the end to fix this issue.

7 day moving average =
CALCULATE (
    SUM ( 'PCR TEsting Data'[Total Volume of Tests (Excl. work in progress or tests referred out) (No.)] ) / 7,
    DATESINPERIOD (
        'PCR TEsting Data'[Relevant Date],
        LASTDATE ( 'PCR TEsting Data'[Relevant Date] ),
        -7,
        DAY
    )
)

If the above expression does not work, you can also try to use the date function to manually calculate the moving average.

7 day moving average =
VAR currDate =
    MAX ( 'PCR TEsting Data'[Relevant Date] )
VAR prevDate =
    DATE ( YEAR ( currDate ), MONTH ( currDate ), DAY ( currDate ) - 7 )
VAR summary =
    SUMMARIZE (
        FILTER (
            ALLSELECTED ( 'PCR TEsting Data' ),
            [Relevant Date] >= prevDate
                && [Relevant Date] <= currDate
        ),
        [Relevant Date],
        "Total", SUM ( 'PCR TEsting Data'[Total Volume of Tests] )
    )
RETURN
    AVERAGEX ( summary, [Total] )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

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!

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.

Users online (25)