Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hi all,
I am attempting to use Power Bi to make dynamic X and Rbar control charts that are used in quality control, statistical process control. I don't want to get to jargon-y, so I will try to explain the specific calculations I need to make without getting to far into control charts. But if you want more info, you can look here https://www.spcforexcel.com/knowledge/variable-control-charts/xbar-r-charts-part-1.
Here is an example of my data structure.
| Batch | Sample | Value |
| A | A1 | 200.1 |
| A | A2 | 300.5 |
| A | A3 | 134.7 |
| B | B1 | 200.1 |
| B | B2 | 300.5 |
| C | C1 | 250.5 |
| C | C2 | 50.7 |
| C | C3 | 692.1 |
| C | C4 | 237.9 |
where Batch is a unique product batch, Sample is a sample of a manufactured item within that batch, and Value is some quantifiable measure (weight, length, concentration, etc).
To make my xbar and R chart, I need to be able to calculate and plot:
xbar- this is the overall average of the batch averages. So if I took the average value of batch A, B and c separately, then averaged those 3 values
rbar- this is the overall average of the batch value rage. So if I took the range value of batch A, B and C separately, then averaged those 3 values
I am able to use code like that below to calculate xbar as a measure.
xbar:=averagex(summarize(Table,[Batch],"Example",average([Value])),[Example])
However, if I try to plot this value with Batch vs. Value on the x and y axes, the value of xbar will be evaluated at the specified level of batch. Instead, I need the value of xbar that is the average of all batch averages -- which will be the same for all batches.
Is there a way to use the measure in the way described or do I need to take a different approach??
Solved! Go to Solution.
xbar:=CALCULATE ( SUM ( [Value ), ALLSELECTED( Table ) )
/ CALCULATE ( COUNT (Table[Batch]), ALLSELECTED( Table) )For those interested, this was the solution to my problem.
xbar:=CALCULATE ( SUM ( [Value ), ALLSELECTED( Table ) )
/ CALCULATE ( COUNT (Table[Batch]), ALLSELECTED( Table) )For those interested, this was the solution to my problem.
you can use ALL() in dax to remove any filter context from a table
xbar:=averagex(summarize(Table,[Batch],"Example",average([Value])),[Example])
using ALL(Table) might work for you
but SUMMARIZE is a lot more complicated than it looks
if you want to go into it and understand just what is going on take a look at https://www.sqlbi.com/articles/all-the-secrets-of-summarize/
Help when you know. Ask when you don't!
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 3 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |