Forum Discussion
Apply Filter before Calculating Average
I have the following product-state-date sales data:
| Date | State | Product | Damage% | Sales | Costs |
| 10/01/2026 | NSW | Banana | 0.1100 | 5000 | 2985 |
| 10/01/2026 | QLD | Banana | 0.0900 | 3500 | 2035 |
| 10/01/2026 | VIC | Banana | 0.1500 | 3800 | 2157 |
| 10/01/2026 | NSW | Apple | 0.0570 | 4400 | 3244 |
| 10/01/2026 | QLD | Apple | 0.2100 | 2980 | 1859 |
| 10/01/2026 | VIC | Apple | 0.0490 | 3215 | 2470 |
| 11/01/2026 | NSW | Banana | 0.1045 | 5190 | 2835 |
| 11/01/2026 | QLD | Banana | 0.0855 | 3633 | 1933 |
| 11/01/2026 | VIC | Banana | 0.1425 | 3944 | 2049 |
| 11/01/2026 | NSW | Apple | 0.0542 | 4567 | 3081 |
| 11/01/2026 | QLD | Apple | 0.1995 | 3093 | 1766 |
| 11/01/2026 | VIC | Apple | 0.0466 | 3337 | 2346 |
| 12/01/2026 | NSW | Banana | 0.1035 | 4855 | 3029 |
| 12/01/2026 | QLD | Banana | 0.0847 | 3399 | 2065 |
| 12/01/2026 | VIC | Banana | 0.1412 | 3690 | 2189 |
| 12/01/2026 | NSW | Apple | 0.0536 | 4272 | 3292 |
| 12/01/2026 | QLD | Apple | 0.1976 | 2894 | 1886 |
| 12/01/2026 | VIC | Apple | 0.0461 | 3122 | 2507 |
I have the PowerBI summarised table for all 3 day's results (note: we just want to summarise by Product-State and not date):
What I want to do is create a filter measure to allow me to filter out those product-state-date where the Damage% is greater than a certain threshold (eg.11%). I created the following measure:
I then place "Filter_DamageThreshold" in the Filter section of the above summary table and select value of "1"
The result is that it is only filtering out the following rows:
What I really want to do is to filter out those product-state-date with Damage% greater than or equal to 11% first and then calculate the summary table. Below rows in yellow is what I want to filter out or exclude from the dataset first:
...and then calculate the summary table therefore giving the following results:
Your visual-level filter measure is evaluated at the current visual grain (Product-State), not at the underlying Product-State-Date row level, so it won’t exclude date rows first. Use the threshold condition inside each aggregation measure instead:
Threshold % = 0.11Sales (Filtered) = VAR T = [Threshold %] RETURN CALCULATE( SUM('Fact'[Sales]), KEEPFILTERS( FILTER('Fact', 'Fact'[Damage%] < T) ) )Costs (Filtered) = VAR T = [Threshold %] RETURN CALCULATE( SUM('Fact'[Costs]), KEEPFILTERS( FILTER('Fact', 'Fact'[Damage%] < T) ) )Damage % (Filtered) = VAR T = [Threshold %] RETURN CALCULATE( AVERAGE('Fact'[Damage%]), KEEPFILTERS( FILTER('Fact', 'Fact'[Damage%] < T) ) )Hi,
PBI file attached.
Hope this helps.
5 Replies
- jgeddesSuper User
The solution provided by cengizhanarslan will work 100%. Another method to solving this is using the 'X' functions. In this case SUMX and AVERAGEX, with a filtered table input. As an example...
Average Damage (Excess damage removed) = AVERAGEX( FILTER('Table', 'Table'[Damage%] < 0.11), 'Table'[Damage%] )As in the other solution you can create a measure or parameter for the threshold value and reference to it in this measure. I hardcoded it for simplicity.
Cheers. - cengizhanarslanSuper User
Your visual-level filter measure is evaluated at the current visual grain (Product-State), not at the underlying Product-State-Date row level, so it won’t exclude date rows first. Use the threshold condition inside each aggregation measure instead:
Threshold % = 0.11Sales (Filtered) = VAR T = [Threshold %] RETURN CALCULATE( SUM('Fact'[Sales]), KEEPFILTERS( FILTER('Fact', 'Fact'[Damage%] < T) ) )Costs (Filtered) = VAR T = [Threshold %] RETURN CALCULATE( SUM('Fact'[Costs]), KEEPFILTERS( FILTER('Fact', 'Fact'[Damage%] < T) ) )Damage % (Filtered) = VAR T = [Threshold %] RETURN CALCULATE( AVERAGE('Fact'[Damage%]), KEEPFILTERS( FILTER('Fact', 'Fact'[Damage%] < T) ) ) - Ashish_MathurSuper User
- v-pnaroju-msftCommunity Support
Thankyou, cengizhanarslan, jgeddes and Ashish_Mathur for your responses.
Hi powerlight1,
We appreciate your inquiry through the Microsoft Fabric Community Forum.
We would like to inquire whether have you got the chance to check the solutions provided by cengizhanarslan, jgeddes and Ashish_Mathur to resolve the issue. We hope the information provided helps to clear the query. Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.
Thank you. - v-pnaroju-msftCommunity Support
Hi powerlight1,
We are following up to see if what we shared solved your issue. If you need more support, please reach out to the Microsoft Fabric community.
Thank you.