I know that this topic has been covered before by others, but I think it’s still pretty valuable for a user to be able to figure out what Power Query functions exist, especially since they are often different than what we’re used to in Excel.
NOTE: This article was updated 2015-05-20 at the request of a reader to include more coverage on implementing the discovered function into the solution.
Power Query Functions Documentation on the web
There’s a pretty good resource site available on the Microsoft Support site. Personally I have that one bookmarked and head over there often when I’m looking for a new function to do something. I find that with a quick CTRL + F on the page, I can quickly search and narrow in on the function I think I need in order to learn it’s syntax.
To be fair, I’m not always in love with the actual examples (many lack a power query UI view), but overall the site is fairly useful.
Power Query Functions Documentation in the client
Now that’s all good, but what if you’re working on a plane with no WIFI, and you need to figure out the syntax for a new function?
As luck has it, there is a way to pull up the list for most functions right in the client. To do this, I:
- Clicked Add Column –> Add Custom Column
- Typed a 1 and clicked OK
- Went to the Power Query formula bar and typed the formula below. (Notice that this is case sensitive)
(Why the custom column? Because typing in the formula bar replaces the previous step, and I want to be able to revert to that since it’s part of my logic:
Now, you’ll see you get a list of (almost) all the functions that you can access:
Now, let’s assume I’m trying to find a formula to remove certain characters from a text string. I really need to search for “Text.”, but there isn’t a search option. No big deal, let’s convert this list into a table:
Once we’ve done that, we get a nice table of all of the functions, and we can filter them to our heart’s content. Here’s my table filtered down to just rows that begin with “Text”:
And a page or so down, I found something that looks like it might work: Text.Remove.
Investigating the Function Syntax
I clicked on the green Function beside the Text.Remove entry. It pops up an Invoke Function box, and behind that is the syntax for how it’s supposed to work. So that’s pretty cool. I tried it out with some text, as shown below:
Clicking OK returned the following:
Now this is a bit… weird… and frustrating. Value? Why Value? (I actually don’t know why, you’d think it would have been the function name, wouldn’t you?)
I stepped back to the Value step of the query, as I wanted to look at the syntax page that popped up behind the Invoke Function dialog:
My only complaint here is that once you land in this window, the only indicator of the actual function name is in the smallest font on the page, buried in the middle. You’d think that the name would should up a little more prominently. Regardless, I copied the name of the function, then stepped back to the Invoked FunctionValue step and replace Value in the formula bar with the function name:
Perfect, it works.
Implementing the Function in the Solution
Now let’s see if I can get it into my original query. To do that I:
- Copied that entire line of M from the formula bar,
- Selected the Source step (I wouldn’t be able to do this if I had typed #shared while I had the Source step selected originally),
- Choose to Add New Column –> Add Custom Column –> Accept the inserted step,
- Pasted the copied M into the formula area, and
- Replaced the original text (“My –Dog –Has –Fleas”) with the name of the appropriate column from my data set.
Visually, it looks like this:
And then I checked the query to see that it worked:
Learning more about Power Query functions
For reference, this is one of the many things that Miguel and I will be covering in our upcoming Power Query training workshops. Learn more about the workshop and register here: http://powerquery.training/course/