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

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

Reply
mrlang02
Frequent Visitor

Ignore measure subgroups when charting and in calculations?

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.  

 

BatchSampleValue
AA1200.1
AA2300.5
AA3134.7
BB1200.1
BB2300.5
CC1250.5
CC250.7
CC3692.1
CC4237.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.  

https://ibb.co/cwLJzLn

Is there a way to use the measure in the way described or do I need to take a different approach??

1 ACCEPTED SOLUTION
mrlang02
Frequent Visitor

xbar:=CALCULATE ( SUM ( [Value ), ALLSELECTED( Table ) )
    / CALCULATE ( COUNT (Table[Batch]), ALLSELECTED( Table) )

For those interested, this was the solution to my problem.

View solution in original post

2 REPLIES 2
mrlang02
Frequent Visitor

xbar:=CALCULATE ( SUM ( [Value ), ALLSELECTED( Table ) )
    / CALCULATE ( COUNT (Table[Batch]), ALLSELECTED( Table) )

For those interested, this was the solution to my problem.

kentyler
Solution Sage
Solution Sage

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/ 





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.