Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
power query m. change step names from #"name something" to NameSomething. Are there any issues around renaming to pascal case and removing the #"" wrapper?
The #"" wrapper gives me the heebee jeebees :}
Is there a valid reason to use the #"" wrapper for step naming? I would prefer to rename all my steps to PascalCase meaningful names.
This may be my just needing to accept the #"" wrapper just like I did with TSQL all those years ago. ie 'table'.[column]
Where now when writing TSQL I always use the '' table and [] column wrappers regardless if needed or not.
Thoughts?
AI response was that I needed the #"" wrapper for underscores but this has not been the situation for pqm I have written.
For example, screen shots from recent post
The key didn't match any rows in the table. Does data model table order matter?
Solved! Go to Solution.
Hi @garythomannCoGC ,
There's no reason you can't change the step names to avoid the #"" wrapper. I do it in all of my M code, albeit in camelCase, rather than PascalCase. It makes the code way easier to read, in my opinion, and allows you to see what's happening in the query at a glance from the step list.
For example, rather than 'Added Column' in the step list (#"Added Column" in code), I will explicitly name the step with with column was added, like 'addSalesRevenue' etc.
The reason the wrapper is added in the first place is that step names in M aren't just labels for the step, they're table names i.e. every step holds the recipe to form a particular/distinct table (by tracking back through the previous step arguments).
Pete
Proud to be a Datanaut!
Thanks guys, much appreciated. Nice ahha moment thinking about each step as a table of values.
And #table is part of the lexicon of the m language.
Hi @garythomannCoGC ,
There's no reason you can't change the step names to avoid the #"" wrapper. I do it in all of my M code, albeit in camelCase, rather than PascalCase. It makes the code way easier to read, in my opinion, and allows you to see what's happening in the query at a glance from the step list.
For example, rather than 'Added Column' in the step list (#"Added Column" in code), I will explicitly name the step with with column was added, like 'addSalesRevenue' etc.
The reason the wrapper is added in the first place is that step names in M aren't just labels for the step, they're table names i.e. every step holds the recipe to form a particular/distinct table (by tracking back through the previous step arguments).
Pete
Proud to be a Datanaut!
First, you need to understand that we're talking about MCode here, not the UI. Open the advanced editor and look at the MCode; that's what Power Query actually is.
All languages have certain characters that you can't use in code. So, if you have a "Changed Type" step (with a space), then for Power Query, "Changed" and "Type" are two separate words. In order for it to be recognized as one word, something must be placed in front of it, hence the #.
"Change Type" without the # is a string in MCode.
let
Source = Excel.CurrentWorkbook(){[Name="Tabelle1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Nr", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Example", each if [Header]="Changed Type" then 1 else 0)
in
#"Added Custom"
That's it.
Andreas.
@AndreasKiller thank you for your kind reply
Yes string literals are "string". Maybe functions are in camel case ie myBeautFunction ()
And step names we make a rule as PascalCase. I suppose I am asking for MCode naming conventions.
To me PascalCase for the step names makes for an easier code read.
And yes I do understand that #"" wrapping is for spaces, prefix numbers and special characters. But avoiding those we can have beautiful code :}
Or am I missing something? Maybe in the MCode road map #"" for step names is a mandatory requirement.
let
Source = Excel.CurrentWorkbook(){[Name = "Tabelle1"]}[Content],
ChangedType = Table.TransformColumnTypes(Source, {{"Nr", type number}}),
AddedCustom = Table.AddColumn(
ChangedType,
"Example",
each if [Header] = "Changed Type" then 1 else 0
)
in
AddedCustom
Also why does MCode always start with the first step called Source and not #"Source" !?
I am sure I was not the only one to be confused when first starting with MCode :}
The Source step does not need the # because Source does not conatin a blank...
If a step contains a blank you get
#"Sour ce"
otherwise you get
Source
The same is for any other step
#"Changed Type"
versus
ChangedType
So if you record MCode using the UI and you want to remove the # step names, rename each step in the UI and remove the blanks.
Andreas.