Another week another blog!! This week we will be focusing on the optimising the bad performing measures and how to tackle the measures generating Call back ID. Before starting, this blog is intended for Users who are a bit familiar with DAX Studio if not then you can do a quick read on our most read blog on our website (link).
Performance of report is a great factor in improving in the user experience and to check how well your visuals and DAX formulas are performing you can utilise the benefits of Performance Analyser. In my experience Performance analyser along with the DAX Studio is a match made in heaven. You can copy the query from Performance analyser and evaluate in DAX Studio. To know more about how performance analyser works do visit this interesting article (link).
Let's get our hands dirty and see how you can evaluate your DAX formulas. To do so I have created a basic DAX with help of Filter function
Now, we have included this measure in a table along with the year coming from date table. Also, we have started recording with the help of Performance Analyser. Since our table is taking the most time to render let's evaluate the query running behind our DAX.
To do so you can copy query and go to DAX Studio with the connection to the same PBIX. Once you paste the copied query enable the server timings and query plan from top.
Now run the copied query and go to the server timings. What the heck is going on here? FE? SE? If you are not a fan of acronyms like me then FE stands for Formula engine while the SE stands for Storage Engine.
What does the FE and SE do? Here I would like to quote Data Mozart aka Nikola. Here is the link to the detailed article focusing on the concepts of SE and FE.
When you send the query to get data for your Power BI report, here is what happens:
- Formula Engine (FE) accepts the request, process it, generates the query plan and finally executes it
- Storage Engine (SE) pulls the data out of Tabular model to satisfy the request issued within the query generated by the Formula Engine
In simpler language FE act as a first layer and execute the DAX query as a rule of thumb do keep an eye on the number of queries generated in both Formula engine (FE) and Storage engine (SE). In this case, we have 3 queries running in background for this DAX. You can check the background query by clicking on every query. Now, let's optimise this by removing the Filter function in the DAX and repeat the same exercise.
With a slight change in the DAX we have reduced the number of background queries also we have reduced the total duration from 17ms to 7ms. What has changed in the DAX?
Sales 100 filter = Calculate (Sum(Sales), 'Sales' > 100)
Isn't this amazing? Let's take it to the next level. On the journey of optimising the DAX you may encounter the concepts of Call Back ID. What is that? SE provides a data cache to FE but there are specific cases where the SE is unable to identify the DAX expression and ask the Call back ID to FE.
Rule of thumb here states that try to get rid off the call back data ID because ultimately it slows down the performance of your DAX. The most common question here will be what are those DAX then can create Call back data ID.
Perfect example for this will be use of IF function along with the iterators such as SUMX, AVGX and many more functions with X as a suffix to them. We have a created a measure with the same and we will see how call back data IDs are generated with just 3-4 lines of measures.
To identify the queries that are generating the call back data ID once you check all the queries the one having the call back data ID it should be highlighted like mentioned in the image above. Also, note the total duration and the number of queries running in the background.
To improve this and as a part of best practices in optimising the DAX try not to combine the IF and iterator functions together instead use variables which can the eliminate the call back data ID.
"All our articles are intended to address all the frequently asked questions related to a topic. Do leave a comment if it answers any of your question. "
Thanks for Reading Let's connect on LinkedIn. For more such blogs and pro tips do follow us
Great Blog.
ReplyDelete