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
cbruhn42
Helper II
Helper II

Creating Control Charts - Moving Range Average Calculation

I'm trying to calculate the average moving range for one of my control charts and having trouble.

 

I found the code below to create a measure to calculate the moving range and this works.  However, I now need to calculate the average of these values to plot on my chart as the center line.  Any thoughts?

 

VAR EarlierTime =
CALCULATE (
MAX ( 'Final FV Alcolyzer Data (2)'[Alcolyzer DT] ),
FILTER (
ALLSELECTED ( 'Final FV Alcolyzer Data (2)'[Alcolyzer DT] ),
'Final FV Alcolyzer Data (2)'[Alcolyzer DT] < SELECTEDVALUE ( 'Final FV Alcolyzer Data (2)'[Alcolyzer DT] )
)
)
VAR EarlierMeasureValue =
CALCULATE ( SUM ( 'Final FV Alcolyzer Data (2)'[Value] ), 'Final FV Alcolyzer Data (2)'[Alcolyzer DT] = EarlierTime )
RETURN
IF(ISBLANK(EarlierMeasureValue), blank(), ABS ( EarlierMeasureValue - SUM ( 'Final FV Alcolyzer Data (2)'[Value] ) )

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @cbruhn42 

 

Assume that your current measure is called "Moving Range" and that you want to calculate the average of it over the x-axis field (I guess it is 'Final FV Alcolyzer Data (2)'[Alcolyzer DT]), you may try below measure

Average Measure =
VAR allValueTable =
    SUMMARIZE (
        ALLSELECTED ( 'Final FV Alcolyzer Data (2)'[Alcolyzer DT] ),
        "moving_range", [Moving Range]
    )
RETURN
    AVERAGEX ( allValueTable, [moving_range] )

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

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.