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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Enan
Helper I
Helper I

Difference Between Calculate & Filter

Hi Experts,
 
Need your guidance to understand the behaviour of Filter & Calculate.
I have used below DAX measures to calcualte total Transactions based where quantity =6 and for Jan97.
However when i use the slicer and slect quantity less than 06 it gives blank value for PINK text box (Filter DAX used) but when i nothing changes in Blue Text Box (Calcualte use).
 
Can you please guide me how it is working.
Below images and DAX are for your inforamtion:
 
No Slicer SelectedNo Slicer SelectedSlicer Value SelectedSlicer Value Selected
Total Transaction Jan97 & Qty equals 6 using Filter = CALCULATE(COUNTROWS(
    FILTER(Transactions_Data_Fact,Transactions_Data_Fact[quantity]=6 &&
     Transactions_Data_Fact[year]=1997 &&
     Transactions_Data_Fact[Month] =1)))
 
Total Transaction Jan97 & Qty equals 6 using Calculate = CALCULATE(COUNTROWS(Transactions_Data_Fact),
Transactions_Data_Fact[quantity]=6,
Transactions_Data_Fact[year]=1997,
Transactions_Data_Fact[Month]=1)
1 ACCEPTED SOLUTION
MarkLaf
Solution Sage
Solution Sage

Refer to this sqlbi article: https://www.sqlbi.com/articles/filter-arguments-in-calculate/

MarkLaf_0-1679961858693.png

To directly try to answer your question, filters statements in CALCULATE that don't explicitly use FILTER are implicitly using FILTER( ALL( Table[Column] ), <condition> ). I.e. your 'using Calculate' version is equivalent to:

 

= CALCULATE(
    COUNTROWS( Transactions_Data_Fact ),
    FILTER( ALL( Transactions_Data_Fact[quantity] ), Transactions_Data_Fact[quantity] = 6 ),
    FILTER( ALL( Transactions_Data_Fact[year] ), Transactions_Data_Fact[year] = 1997 ),
    FILTER( ALL( Transactions_Data_Fact[Month] ), Transactions_Data_Fact[Month] = 1 )
)

 

 

 

View solution in original post

1 REPLY 1
MarkLaf
Solution Sage
Solution Sage

Refer to this sqlbi article: https://www.sqlbi.com/articles/filter-arguments-in-calculate/

MarkLaf_0-1679961858693.png

To directly try to answer your question, filters statements in CALCULATE that don't explicitly use FILTER are implicitly using FILTER( ALL( Table[Column] ), <condition> ). I.e. your 'using Calculate' version is equivalent to:

 

= CALCULATE(
    COUNTROWS( Transactions_Data_Fact ),
    FILTER( ALL( Transactions_Data_Fact[quantity] ), Transactions_Data_Fact[quantity] = 6 ),
    FILTER( ALL( Transactions_Data_Fact[year] ), Transactions_Data_Fact[year] = 1997 ),
    FILTER( ALL( Transactions_Data_Fact[Month] ), Transactions_Data_Fact[Month] = 1 )
)

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors