cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MG86
Helper I
Helper I

Calculated Column: Which syntax is better?

Hi, mostly just curious here as both work, but also wanting to optimize for performance:

 

I have a Projects table with a row for every project status mutation. So a project can be New, go into Quotation, go into Accepted, go into Production, get Invoiced etc. Basically a funnel. Now it happens that some projects have gone into Quotation multiple times, and I want to retrieve the earliest date that a project went into Quotation in a Calcultated Column.

 

Given that, which is the better syntax:


Syntax A:

 

VAR Projectnr = 'Projects'[Projectnumber]

RETURN

    MINX (

        FILTER (

            'Projects',

            'Projects'[Projectnumber] = Projectnr

                && 'Projects'[statusnr] = 14

        ),

        'Projects'[Date]

    )

 

Syntax B:

 

VAR Projectnr = 'Projects'[Projectnumber]

RETURN

    CALCULATE (

        MIN ( 'Projects'[Date] ),

        FILTER (

            'Projects',

            'Projects'[Projectnumber] = Projectnr

                && 'Projects'[statusnr] = 14

        )

    )

 

 

I wonder if there is a core difference between these two and if so what is the difference in characteristics (speed, higher chance of unexpected results)?

 

As Syntax A uses CALCULATE I wonder if that induces a less optimal context transition based calculation whereas Syntax B might not use context transition? Or do they both use context transition but is it not implicit in the syntax with Syntax B?

 

Also, is there a way to measure performance for Calculated Columns in a similar way you can use performance analyzer for report visuals?

1 REPLY 1
yingyinr
Community Support
Community Support

Hi @MG86 ,

A Calculated Column is processed at Refresh time, and the result will be stored in the memory. Therfore, you can see the physical column added to an existing table in your model when go to the "Data" tab. Base on my research, I did not find any tool to monitor the running speed and performance of the calculated column. In addition, about the MIN and MINX used in the two calculation columns you mentioned, you can refer to the following blogs to find more.

Difference Between MIN, MINA, MINX In DAX

Improve Power BI Performance by Optimizing DAX

Best Regards

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

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show Episode 10 Recap

The Power BI Community Show

Watch the playback when Amit Chandak, a Power BI Super User, demos how to use Field Parameters to make reports more dynamic.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.

Top Solution Authors