cancel
Showing results for
Did you mean:

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

Frequent Visitor

## Why is CALCULATE() Requiring FILTER() to be used if it it is built in?

My calculate formula does not work without the FILTER() function in it even though I thought filter was a part of it, and filter does not work without another function like ALL() or ALLSELECTED() in it, and I don't think I really want either of those since the formula does not work once I remove filters from the filter pane. Can anyone possibly explain this?

This works:

CALCULATE([Total Inc], FILTER(ALLSELECTED(Append), Append[Rank2] = current_rank-1))

These do not work:
CALCULATE([Total Inc], FILTER(Append, Append[Rank2] = current_rank-1))
CALCULATE([Total Inc],  Append[Rank2] = current_rank-1)
1 ACCEPTED SOLUTION
Community Support

Hi @dgreen1

When you use FILTER within CALCULATE, you're explicitly defining a new filter context for the calculation. FILTER returns a table that is then used by CALCULATE to modify the existing filter context.

1. Your Working Example: CALCULATE([Total Inc]FILTER(ALLSELECTED(Append), Append[Rank2] = current_rank-1)) works because it does two things:

• ALLSELECTED(Append): This part is removing the filters from the table 'Append' but keeps filters that come from user interactions (like slicers or filters in the filter pane).
• Append[Rank2] = current_rank-1: This part applies a new filter where column 'Rank2' value is equal to current_rank-1 .

2. Why Other Formulas Don't Work:

• CALCULATE([Total Inc], FILTER(Append, Append[Rank2] = current_rank-1)): Here, you are filtering the 'Append' table, but you are not removing any existing filters. If there are other filters in place that conflict with 'Append[Rank2] = current_rank-1', your result might be unexpected or blank.
• CALCULATE([Total Inc],  Append[Rank2] = current_rank-1): This formula is not using FILTER, so the filter context is only altered by 'Append[Rank2] = current_rank-1'. If there are other existing filters on the table 'Append', they will remain in place and could conflict with your condition.

Best Regards,

Jayleny

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support

Hi @dgreen1

When you use FILTER within CALCULATE, you're explicitly defining a new filter context for the calculation. FILTER returns a table that is then used by CALCULATE to modify the existing filter context.

1. Your Working Example: CALCULATE([Total Inc]FILTER(ALLSELECTED(Append), Append[Rank2] = current_rank-1)) works because it does two things:

• ALLSELECTED(Append): This part is removing the filters from the table 'Append' but keeps filters that come from user interactions (like slicers or filters in the filter pane).
• Append[Rank2] = current_rank-1: This part applies a new filter where column 'Rank2' value is equal to current_rank-1 .

2. Why Other Formulas Don't Work:

• CALCULATE([Total Inc], FILTER(Append, Append[Rank2] = current_rank-1)): Here, you are filtering the 'Append' table, but you are not removing any existing filters. If there are other filters in place that conflict with 'Append[Rank2] = current_rank-1', your result might be unexpected or blank.
• CALCULATE([Total Inc],  Append[Rank2] = current_rank-1): This formula is not using FILTER, so the filter context is only altered by 'Append[Rank2] = current_rank-1'. If there are other existing filters on the table 'Append', they will remain in place and could conflict with your condition.

Best Regards,

Jayleny

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.