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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bpmccain
New Member

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors