Forum Discussion

yigitersann's avatar
yigitersann
Frequent Visitor
3 years ago
Solved

Reading the Dax Code Easily

Hi everyone, First of all I am new to PBI.   I have a sample table including measures and report created from it. For these measures, I'm trying to understand what exactly the code is doing f...
  • Greg_Deckler's avatar
    Greg_Deckler
    3 years ago

    yigitersann Commenting code is always a recommended best practice for all coding languages, including DAX. You can also use the Description metadata field to help document or explain your calculation as well. 

     

    Also, if you want to really understand what is happening at each step of a calculation, use VAR's and then you can return what is in the VAR as the RETURN for the measure and essentially kind of step through the calculation, seeing what each VAR contains as you go. I often use CONCATENATEX to do this for a table VAR which is also yet another reason why I don't tend to use CALCULATE because CALCULATE obfuscates what is going on internally. https://youtu.be/meh3OkgFYfc

     

    DAX Studio is really more about returning tables of values versus measures that return scalar values (single values, not a table of values). That is why your measure code doesn't work in it.