Strings and single quotes

When programming in DAX you can use both double quotes ” and single quotes ‘ to contain strings. You must use double quotes when using labels, but aside from that, functionally they work the same.

One consideration is the best practices. Personally I use compile level 4, which will flag up unused variables and lots of useful information to keep your code clean, but it also flags up strings that are not labels. This is often a problem with data migration scripts as you will often use strings, but wont want to create DAX labels for them. You also don’t want the best practice engine from flagging them up, so the best course of action is to use single quotes to contain the strings as this will not cause a best practice warning.

If when using single quotes and you want to include a single quote within the string, you need to ensure you use \’ where you want the single quote, as this will be interrupted as a single quote within a string.