cancel
Showing results for 
Search instead for 
Did you mean: 
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
Super User
Super User

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
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors
Top Kudoed Authors