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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors