cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
adetogni
Solution Sage
Solution Sage

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




3 REPLIES 3
parry2k
Super User
Super User

@adetogni 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






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.





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....





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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






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
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors