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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
geiratatea
Frequent Visitor

Write robust DAX code which is easy to debug and performs well

Hi!

 

I have a very general question but I think many developers are searching for an best possible approach writing good dax formulas. Few days ago I saw a nice written dax code (which I cannot remember:-( ) But anyway, it was building a measure, that first created some selected filters into some variables, then it started to build up a virtual small table and added the filter sto it.

 

Next, it added one column through the ADDCOLUMNS functions which also included some local variables and additional logic.

 

The again a new variable filter was created, and put into the virtual table. And so on... Finally we get a spot on data table where we could the measure value we wanted. I though this was an elegant way to create measures and perhaps it is easier to debug the dax code as well. And perhaps this approach can even get better performace.

 

So my question is: Is this a good way to write dax code or do you have even better suggestions solving dax calculation problems? Examples would be grate.

 

Regards Geir

1 ACCEPTED SOLUTION

Hi @geiratatea ,

Please review the following links, hope they can help you.

DAX Best Practice Guide

Optimizing DAX Video Course

HOW TO IMPROVE POWER BI PERFORMANCE - PART II

Use Performance Analyzer to examine report element performance (can see and record logs that measure how each of your report elements performs when users interact with them, and which aspects of their performance are most (or least) resource intensive.)

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.

View solution in original post

3 REPLIES 3
Whitewater100
Solution Sage
Solution Sage

Hi:

There are serveral places to help format code correctly. 

https://www.daxformatter.com/   for one.

 

You can also use DAX Studio, Dax.do. TabularEditor(3)

 

Whitewater100_0-1652126811421.png

You'll notice they have both Long and Short form methodes for writing the code. Any of these choices should help you see the correct(accepted) way of writing DAX. I hope this answers your question. Thanks..

Hi and thanks for responding. I was thinking more in direction of writing dax logic in a best way. Formatting will of course make it easier to read and will gain readability. my question is about breaking down a business problem into smaller pieces of code that can make it easier to solve. Good technique will guilde us to the target I guess

Hi @geiratatea ,

Please review the following links, hope they can help you.

DAX Best Practice Guide

Optimizing DAX Video Course

HOW TO IMPROVE POWER BI PERFORMANCE - PART II

Use Performance Analyzer to examine report element performance (can see and record logs that measure how each of your report elements performs when users interact with them, and which aspects of their performance are most (or least) resource intensive.)

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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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