Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Count number of values within a range of the average of those values
03-20-2024
06:10 PM
Hi,
I have some data similar to what is shown below:
Date | Sample | Value |
March 20th, 2024 | 1 | 5 |
March 20th, 2024 | 2 | 6 |
March 20th, 2024 | 3 | 7 |
March 20th, 2024 | 4 | 3 |
March 20th, 2024 | 5 | 4 |
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 - Sample | Average of Value | Count within 1 of average |
March 20th, 2024 | 3 | 3 |
1 | 5 | 1 |
2 | 6 | 1 |
3 | 7 | 0 |
4 | 3 | 0 |
5 | 4 | 1 |
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 - Sample | Value | Count within 1 of average |
March 20th, 2024 | 3 | 5 |
1 | 5 | 1 |
2 | 6 | 1 |
3 | 7 | 0 |
4 | 3 | 0 |
5 | 4 | 1 |
Any ideas?
Solved! Go to Solution.
1 ACCEPTED SOLUTION
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024
09:10 PM
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
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024
09:10 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024
04:37 AM
Sorry - posted too quickly. Tried again, and it worked. Must not have done it right the first time. Thanks!

Helpful resources
Recommendations
Subject | Author | Posted | |
---|---|---|---|
05-03-2024 03:14 AM | |||
09-06-2024 04:51 AM | |||
09-27-2024 04:38 AM | |||
01-29-2023 08:25 PM | |||
Anonymous
| 05-25-2020 10:08 AM |
Top Solution Authors (Last Month)
User | Count |
---|---|
14 | |
13 | |
11 | |
10 | |
8 |