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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dhanekula1996
Helper I
Helper I

Dynamic mean for control charts based on rules

Hello,
I am trying to create a control chart based on a set of rules. My mean and standard deviation should change based on set of mentioned rules. Standard rules to calculate the control chart are as follows
1. to calculate mean/ average the minimum data points are 5.

2. To calculate standard deviation the minimum data points are 15.
The required rules for the visualization
1. If seven consecutive points appear above or below the MEAN, the MEAN for the past seven points is recalculated. This is where we would look at the seven points ahead from the first point where it changed.
2. If seven consecutive points are moving either up or down the MEAN is recalculated on the past seven points. This again is where we would look at the seven points ahead from the first point where it changed.

3. If fifteen consecutive points are within +/- 1.0 standard deviation of the MEAN, the standard deviation, UCL and LCL are recalculated. Beginning to the system change point (back to the start of the 15 data points that triggered the recalc). Newly calculated means and standard deviations are used for rule evaluation on the next data points

Sample data is as follows:
 Fiscal_Week    Returns
5/7/2022         4630
5/14/2022       4800
5/21/2022       5069
5/28/2022       2789
6/4/2022         4596
6/11/2022      5275
6/18/2022      5172
6/25/2022      5219
7/2/2022        5101
7/9/2022        5020
7/16/2022       5327
7/23/2022       5001
7/30/2022       5221
8/6/2022         5309
8/13/2022       5225
8/20/2022       5475
8/27/2022       5291
9/3/2022         5371
9/10/2022       4961
9/17/2022       5091
9/24/2022       5355
10/1/2022       4049
10/8/2022      4729
10/15/2022      4869
10/22/2022      4417
10/29/2022      4030
11/5/2022      3698

Sample graph :
Note: Not based on above mentioned data

dhanekula1996_0-1669141045053.png

@amitchandak @Greg_Deckler @Mikelytics @mangaus1111 

2 REPLIES 2
djurecicK2
Super User
Super User

Hi @dhanekula1996,

 You should probably create measures to do all of these calculations, then add the measures to a visual.

 

Power BI does have a standard deviation function:

https://learn.microsoft.com/en-us/dax/stdev-p-function-dax

 

I have tried this for Average calculation but this measure gives me a constant Average value. I need to dynamically vary the average based on the rules mentioned.

Avg Returns_c = CALCULATE(AVERAGEX('01_Date',[ITEM return rate]),ALLSELECTED('01_Date'[Calendar_Date]))

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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