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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.