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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
dgreen1
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
v-jialongy-msft
Community Support
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.

View solution in original post

1 REPLY 1
v-jialongy-msft
Community Support
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.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.