Forum Discussion
powerlight1
6 months agoHelper I
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 ...
- 6 months ago
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) ) ) - 6 months ago
Hi,
PBI file attached.
Hope this helps.
cengizhanarslan
6 months agoSuper 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) )
)