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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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
Most Valuable Professional
Most Valuable Professional

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
Most Valuable Professional
Most Valuable Professional

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? (Yes, its FREE!)
➤ 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/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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