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.
Hi Community Champions,
I have a simple DAX code, and i wrote it as shown below:
And I thought I was doing okay with formatting here until i went to DAXFORMATTER.COM and it suggested this code be formatted as below:
I am really interested to understand why DaxFormatter thinks their way is better. Actually, I feel the same too since it is easier on eyes and facilitate comprehension- but want to understand why is it that sometime we should indent using Shift + Enter and sometimes not as in this case.
I was researching more about formatting tips and found this on SQLBI
"Write a function inline only if it has a single argument that is not a function call"
Does this line explain what I am looking for? These words inline & function call went above my head- can somebody explains this and what I am looking for in easier words? However, at the same site I also read a contradictory statement, atleast for my case here:
"Always put arguments on a new line if the function call has 2 or more arguments"
Solved! Go to Solution.
Hi @Anonymous ,
at daxformatter.com you have the possibility to use your own settings (see figure):
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
@FrankAT - Great catch there- that's why I love seeking inputs from professionals like you'll.
However, if by default- the DAX formatter showed a long line for this code- should I assume that as a standard best practice? (I know it's personal choice and that's why so many options in settings too)
I would like to know if the way SQLBI formatted had anything to do with the formatting rules SQLBI has on their site as I mentioned:
"Write a function inline only if it has a single argument that is not a function call"
And then this contrasting statement (I thought, not sure)
"Always put arguments on a new line if the function call has 2 or more arguments"
Hi @Anonymous ,
when creating a formula, whether a DAX formula, Excel formula or programming code, several important aspects are in the foreground for me:
Marco Russo and Alberto Ferrari have done a valuable job with their rules for the formal writing of a DAX formula. Those who adhere to it will be able to work much more easily with DAX formulas. That is to their credit.
Everyone can choose for themselves whether they adhere very closely to this set of rules or acquire their own style in writing DAX formulas.
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
Hi @Anonymous ,
If no one asks you which format you must use explicitly , you can write DAX according to personal habits, but the formula is best to have indentation, so that it is more readable.
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
at daxformatter.com you have the possibility to use your own settings (see figure):
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |