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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dgwoodard
Frequent Visitor

Filtered table help

Hi all,
I hope that I can gain some advice on how to proceed in calculating a simple moving average with a period value depenant upon the variable parameter from a slicer.

The measure I currently have is as follows but the return is blank. The intention is to plot the moving average over top of the original data points to smooth out the volility. The catch is that I am not working with dates but rather with an indexed data set of various measurements.

DIAM_SMA_100 =
var PeriodValue = SELECTEDVALUE('Period Sample'[Period Sample])
var SelectedValue = SELECTEDVALUE('Table'[Index])
 
Return
AVERAGEX(
FILTER('Table',
MAX('Table'[Index])=SelectedValue &&
MIN('Table'[Index])= SelectedValue - PeriodValue),
CALCULATE(SUM('Table'[Measured Value])
))
 
I am still new to DAX and I believe my filter function is filtering evrything out (?). I would appreciate any insight into resolving or of an alternate method.
Thank you!
1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @dgwoodard 

I'd need to see more of the model but try this:

DIAM_SMA_100 V2 =
VAR PeriodValue =
    SELECTEDVALUE ( 'Period Sample'[Period Sample] )
VAR SelectedValue =
    SELECTEDVALUE ( 'Table'[Index] )
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[Measured Value] ),
        'Table'[Index] <= SelectedValue,
        'Table'[Index] >= SelectedValue - PeriodValue
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

2 REPLIES 2
dgwoodard
Frequent Visitor

That was quick! Thank you!

AlB
Community Champion
Community Champion

Hi @dgwoodard 

I'd need to see more of the model but try this:

DIAM_SMA_100 V2 =
VAR PeriodValue =
    SELECTEDVALUE ( 'Period Sample'[Period Sample] )
VAR SelectedValue =
    SELECTEDVALUE ( 'Table'[Index] )
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[Measured Value] ),
        'Table'[Index] <= SelectedValue,
        'Table'[Index] >= SelectedValue - PeriodValue
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.