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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
possible-possum
Frequent Visitor

Calculated columns in DAX vs computed columns in Power Query

I have a couple of date comparison calculations I need to perform in Power BI. Both are very straight forward, but I was wondering what the most efficient way would be to do them.

 

I need a new column in two different tables, which provides a number of months between two dates. I require the column so that I can use it as a row/axis input into visuals in my report. 

 

In one instance, both the date columns are contained within one table. In the other instance, the date columns are in different tables but can be easily accessed through the RELATED function.

 

There are around 80,000 rows in each table I need these columns. In each of these instances, would you use a DATEDIFF function, or would you complete the steps in Power Query instead (including the merge in the second instance)?

 

My data model is not overly large (around 85mb) but my refresh times are beginning to get a bit long (not related to these two tables though), so I am hoping to avoid as many expensive Power Query steps as possible! The new columns will have very low cardinality (a numeric number between -1 and 12) so data model size is not too much of a concern. 

1 ACCEPTED SOLUTION
v-kongfanf-msft
Community Support
Community Support

Hi @possible-possum ,

 

In general, choosing between calculated columns in DAX and calculated columns in Power Query depends on a number of factors, and here are some considerations for both approaches:

  • Calculated columns in DAX:
    Performance: Calculated columns in DAX are computed in the row context of the query, and they can affect query performance. However, for simple calculations, such as the number of months between two dates, the impact is usually negligible.
  • Calculated columns in Power Query:
    Performance: Calculated columns in Power Query are applied during the data loading process and have the potential to improve query performance. These steps are performed in the M language and may be more efficient for some operations.


In your scenario, using calculated columns in DAX is straightforward if the dates are in the same table or if associations can be easily established. You can evaluate the performance impact and adjust your approach based on test results.

 

For more details, you can read below blog:

Comparing DAX calculated columns with Power Query computed columns - SQLBI

 

Best Regards,
Adamk Kong

 

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-kongfanf-msft
Community Support
Community Support

Hi @possible-possum ,

 

In general, choosing between calculated columns in DAX and calculated columns in Power Query depends on a number of factors, and here are some considerations for both approaches:

  • Calculated columns in DAX:
    Performance: Calculated columns in DAX are computed in the row context of the query, and they can affect query performance. However, for simple calculations, such as the number of months between two dates, the impact is usually negligible.
  • Calculated columns in Power Query:
    Performance: Calculated columns in Power Query are applied during the data loading process and have the potential to improve query performance. These steps are performed in the M language and may be more efficient for some operations.


In your scenario, using calculated columns in DAX is straightforward if the dates are in the same table or if associations can be easily established. You can evaluate the performance impact and adjust your approach based on test results.

 

For more details, you can read below blog:

Comparing DAX calculated columns with Power Query computed columns - SQLBI

 

Best Regards,
Adamk Kong

 

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.