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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
bpmccain
Frequent Visitor

Count number of values within a range of the average of those values

Hi,

 

I have some data similar to what is shown below:

DateSampleValue
March 20th, 202415
March 20th, 202426
March 20th, 202437
March 20th, 202443
March 20th, 202454

 

The average of these values is 5, and I want a measure that I can use that shows me the count of values that are +/-1 of that average. The matrix table I would like to show at the end should look like this:

Date - SampleAverage of ValueCount within 1 of average
March 20th, 202433
151
261
370
430
541

 

The expression I am using as a measure is:

 

In Range = 

var _average = Calculate(AVERAGE('Data'[VALUE]),REMOVEFILTERS('Data'[Sample]))

var _delta = abs(average('Data'[VALUE])-_average)

var _inRange = CALCULATE(COUNTA('Data'[VALUE]),FILTER('Data',_delta<=1))

return _inRange

 

What I end up with however is, where the total count is wrong
Date - SampleValueCount within 1 of average
March 20th, 202435
151
261
370
430
541

 

Any ideas?

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

is this ok?

In Range = 

var _average = Calculate(AVERAGE('Data'[VALUE]),REMOVEFILTERS('Data'[Sample]))

var _inRange = CALCULATE(COUNTA('Data'[VALUE]),FILTER('Data',abs('Data'[VALUE]-_average)<=1))

return _inRange

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

is this ok?

In Range = 

var _average = Calculate(AVERAGE('Data'[VALUE]),REMOVEFILTERS('Data'[Sample]))

var _inRange = CALCULATE(COUNTA('Data'[VALUE]),FILTER('Data',abs('Data'[VALUE]-_average)<=1))

return _inRange

Sorry - posted too quickly. Tried again, and it worked. Must not have done it right the first time. Thanks!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.