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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

how to debug (complex) DAX expressions

I consider myself somewhat experienced in DAX, I mean I can do pretty much what I need, even in fairly complex models. However, from time to time, even if I know the inner works of DAX, I would like to "debug" it and see how it calculates what it calculates. 

So when the model is simple, I open a new page, add slicers and tables, apply the filters that I use in the formula and I see the resulting rows that will be used for the calculation. Works, but ... it doesn't when you use inactive relationships, USERELATIONSHIP and CROSSFILTER.

 

When you use these in your code, it generally works, but sometimes...it doesn't. If the model is complex (my current one has 40 tables and more than 60 relationships, and many of them are inactive) trying to "visualize" which rows DAX is considering when doing a calculation can be rather tricky.

Yes DAX studio somewhat helps, but I do feel the need of a "step-by-step" debugger, like when you program in a programming language, that shows you exactly how it goes into a certain table, and which rows is filtering. For example, I have now a complex calculation: the resulting filtered table has 10 rows, but if I do a COUNTROWS of the DAX formula, it returns me 20 rows and I'm really getting mad in understanding what's happening.

Does a tool like this exist? Can DAX studio used for this analysis? Any suggestion? How do you debug complex (complex=with relationships that are activated/deactivated on the fly) expressions? Thanks

3 REPLIES 3
parry2k
Super User
Super User

@Anonymous great questions, based on your post, you know a lot. variable is ofcourse a good to break down DAX, DAX studio helps to debug the performance.

 

Now related to the specific issue your posted, I usually use concatenatex function so that iterate thru the table returned by DAX to see what is going on and/or also create a table using the same expression and see what values (rows) are return and help to debug it further. 

 

Hope this helps. Would like to hear which approach you used or how you solved it?

 

Good luck!!!

 

Best,

Parv



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi Parry

 

I do use CONCATENATEX from time to time, it helps a lot or I replace the calculates with a COUNTROWS. But it is very similar to what we were used to do when we didn't have debuggers: you relied on PRINTSCR, so you print to screen the temporary values to check that everything was right. It somewhat works but it's 10x faster when you have a real debugger....

@Anonymous there is no dedicated debugger, so have to use other techniques.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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