Forum Discussion
Commenting out first line in DAX
Hi
Is it not possible to add comments at the top of a DAX formula?
I type this:
In DAX , the standard way to add comments is either using two forward slashes `//` for single-line comments or the `/* */` syntax for multi-line comments. These comments are generally used to explain the code, making it easier to understand its purpose and functionality.
However, it's important to note that DAX comments are typically not allowed in the names of measures or columns themselves. When you attempt to create a measure and start the definition with a comment, the Power BI or Analysis Services environment might interpret your comment as part of the measure's name if the comment is placed directly above the measure definition without a blank line or is not properly recognized by the editor you're using.
Rejected Closed 2 = // put your comment here VAR RC = SUM('FACT CLAIM'[closed_rejected_count]) RETURN RC
5 Replies
- AmiraBedh
Super User
In DAX , the standard way to add comments is either using two forward slashes `//` for single-line comments or the `/* */` syntax for multi-line comments. These comments are generally used to explain the code, making it easier to understand its purpose and functionality.
However, it's important to note that DAX comments are typically not allowed in the names of measures or columns themselves. When you attempt to create a measure and start the definition with a comment, the Power BI or Analysis Services environment might interpret your comment as part of the measure's name if the comment is placed directly above the measure definition without a blank line or is not properly recognized by the editor you're using.
Rejected Closed 2 = // put your comment here VAR RC = SUM('FACT CLAIM'[closed_rejected_count]) RETURN RC - amitchandak
Super User
Newcolator , Yes, seems like not supported before the measure name.
Please log an issue or idea
Issue -https://community.powerbi.com/t5/Issues/idb-p/Issues
- Sahir_Maharaj
Super User
Hello Newcolator,
Can you please try the following workaround:
1. Start the Formula Normally
Rejected Closed 2 = VAR RC = SUM('FACT CLAIM'[closed_rejected_count]) RETURN RC2. Edit the Formula to Add Comments
// same as rejected closed, but returns nulls for missing data so line charts don't show legends for 0 lines Rejected Closed 2 = VAR RC = SUM('FACT CLAIM'[closed_rejected_count]) RETURN RC3. Use Multi-line Comments as an Alternative
/* same as rejected closed, but returns nulls for missing data so line charts don't show legends for 0 lines */ Rejected Closed 2 = VAR RC = SUM('FACT CLAIM'[closed_rejected_count]) RETURN RCHope this helps!
- _AAndrade
Resident Rockstar
Hi,
If you want to put a description on a measure you can use the description box on the properties ribbon of model view.Output:
Or put your description after define the name of your measure, like this:
- DOLEARY85
Resident Rockstar
Hi,
Comments before measure names is not supported, you can add it after the measure name, on a new line before the statement:
linesRejected Closed 2 =//same as rejected closed, but returns nulls for missing data so line charts don't show legends for 0VAR RC = sum('Table'[Column1])RETURN RCIf I answered your question, please mark my post as solution, Appreciate your Kudos 👍