Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Newcolator
Helper II
Helper II

Commenting out first line in DAX

Hi

 

Is it not possible to add comments at the top of a DAX formula?

 

I type this:

 

// 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 RC
 
When I press enter it adds the second line to the first and calls the measure "// same as rejected...."
 
// same as rejected closed, but returns nulls for missing data so line charts don't show legends for 0 linesRejected Closed 2 =
VAR RC = sum('FACT CLAIM'[closed_rejected_count])
RETURN RC
 
I'm using Nov 2023 version.
1 ACCEPTED SOLUTION
AmiraBedh
Community Champion
Community Champion

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

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

5 REPLIES 5
AmiraBedh
Community Champion
Community Champion

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

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
DOLEARY85
Super User
Super User

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 0
VAR RC = sum('Table'[Column1])
RETURN RC
 
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
_AAndrade
Super User
Super User

Hi,

If you want to put a description on a measure you can use the description box on the properties ribbon of model view.

_AAndrade_0-1708591784884.png

 

Output:

_AAndrade_1-1708591825617.png

 

Or put your description after define the name of your measure, like this:

_AAndrade_2-1708591958430.png

 



 





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Sahir_Maharaj
Super User
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 RC

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

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

Hope this helps!


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
amitchandak
Super User
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

 

Idea - https://ideas.powerbi.com/ideas/

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.