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
cornwall80
New Member

Help with CALCULATETABLE

Hi,

 

I've just started to learn DAX and I'm reading a number of different books including the Definitive Guide to DAX and had a question about the CALCULATETABLE vs. CALCULATE functions.

 

I have tested both these DAX queries and while they produce what looks like the same result set, I was wondering if anyone could tell me if they are in fact syntactically equivalent? Or are there any scenarios when they may produce different results depending on what filters have been applied in the report?

 

The explanation in the book focuses on CALCULATETABLE version and I found what looks like another version of same query online using CALCULATE.

 

Verison 1 with Calculate:

 

BlackTailSpinProds_Calc =
CALCULATE(
    SUM(FactSales[SalesAmount]),
    FILTER(
            ALL(
                DimProduct[BrandName],
                DimProduct[ColorName]
             ),
            AND (
                DimProduct[BrandName]="Tailspin Toys",
                DimProduct[ColorName] = "Black"
            )
    )
)

 

V2 with CALCULATETABLE:

 

BlackTailspinProds_CalcTable =
CALCULATE(
    SUM(FactSales[SalesAmount]),
    FILTER(
            CALCULATETABLE(
                            DimProduct ,
                            ALL( DimProduct[BrandName] ),
                            ALL (DimProduct[ColorName])
             ),
            AND (
                DimProduct[BrandName]="Tailspin Toys",
                DimProduct[ColorName] = "Black"
            )
    )
)

 

Thank you in advance.

 

regards,

 

Andrew

2 REPLIES 2
cornwall80
New Member

Hi Harsh,

 

Thank you for your reply.

 

I have already watched those videos, but unfortunately I wasn't sure if the two DAX queries I posted were semantically equivalent?

 

I  was wondering if you could see any subtle differences between the two queries which may produce different results e.g. for example different filter contexts.  

 

Kind regards,

 

Andrew

harshnathani
Community Champion
Community Champion

Hi @cornwall80 ,

 

You can have a look at these videos and blogs

 

https://community.powerbi.com/t5/Community-Blog/CALCULATE-amp-CALCULATETABLE-What-s-The-Real-Differe...

https://www.youtube.com/watch?v=aA8zIJ-qcO8

https://www.youtube.com/watch?v=mkGyxgQ4n68

 

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

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