文章来源于:https://ssbi-blog.de/technical-topics-english/power-query-editor-using-notepad/

Preface

This post is not new. I published the first version on how to create your own Power Query Editor already in November 2015 on my old blog www.powerbi-usergroup.de. Many things changed since then. First: I changed my blog and created THE SELF-SERVICE-BI BLOG. Second: Many of the details I showed in my older post to create your own editor for Power Query with Notepad++ didn’t work anymore. Several circumstances had changed, so I had to change the post as well. Now let’s go. Get your Power Query Editor ?


Hello  Power Query enthusiasts

many of you know that Power Query is an amazing tool for data import and data transformation. It is powerful an easy to use. But there is always a BUT. It is a pain to write custom M code. The Power Query Advanced Editor comes without intellisense (auto completion), no parameter hintsno syntax highlightingno help texts, which explain what the functions do, no nothing. The fact, that M is case sensitive doesn’t make it easier at all.

In 2015 I read the following article, written by Matt Masson. Matt is a Senior Program Manager at Microsoft and member of the Power BI Developer Team. He showed how to create an editor for Power Query with Notepad++. At that time I did not even know that it was possible to create a custom language in Notepad++. Thanks a lot Matt ?

Matt’s tool already had intellisense and syntax highlighting. What I was still missingwas parameter hints and help texts. The number of Power Query functions are getting more every month and I am always looking for the right function for my specific problem. This is why I was investigating a bit and found a solution, which I hope will be helping others as well.

I use my editor mainly in two scenarios:

Scenario 1: Finding the right function for my problem

Using the editor makes it much easier to find the function that fits your needs. Especially the help texts help you to get more familiar with the M language.

Scenario 2: Taking a look at M code with highlighted keywords and comments

Working with highlighted syntax for Power Query M code

Syntax highlighting helps to keep (or get) an overview over your M codeCommenting becomes more important, the longer and complex your M code gets.

If you are dealing with these scenarios as well and you find my solution interesting, please read further and learn how to get it. It is completely FREE and will take your M Code to the next level ?

Let’s see how to get there.

What you need to do to get your Power Query Editor

Creating your own M editor in Notepad++ is not complicated and can be seperated in the following steps:

  1. Download Notepad++
  2. Creating Keywords highlighting via the GUI of Notepad++
  3. Adding parameter hints and help texts by using a specific XML file

I will guide to create your editor. Stay tuned ?

1. Download Notepad++

Of cause you need to download the free tool Notepad++ (e. g. from here).  I installed the first version (“Take this one if you have no idea which one you should take“) on my machine.

2. Creating Keywords highlighting via the GUI of Notepad++

After you installed the software you need to do some modification in Notepad++. Go to Language and choose Define your language…

Define your own language

The form for defining the user defined language opens. Choose Create New… and give your language a name. I called it M.

Create a new language: M

Now you have to define special keywords and their styles. Go to tab Keywords Lists and fill the first group with all the functions from Power Query. (I provide this list for you at the very end of this article. Go there and click the link list of functions for keywords highlighting). Mark everything in Excel (ctrl + a), then copy (ctrl + c), move to 1st Group in Notepad++ and paste all the function into that box (ctrl + v). The result looks like this:

Add all functions as keyword

Then press Styler and style the keywords as you like it. I decide turn all my function keywords in deep blue and bold letter.

Style your keywords as you like it

Take care also to select the check box for prefix mode. That way your keyword only get styled, when it is used as a prefix. And now comes one of the most important steps: Don’t ignore case ?

M is case sensitive: Don’t ignore case in Power Query

After we have defined all functions as keywords, we need to add some more keywords. The list of keywords is not complete. Feel free to add specific keywords and adjust the styles as you like it.

Define keywords for the Power Query language M

For your convenience copy the following words into the groups:

Group 2: let in

Group 3: each and as error true false is meta not or section shared type

Group 4: if then else

Group 5: try otherwise

Group 6: #binary #date #datetime #datetimezone #duration #infinity #nan #sections #shared #table #time ; Because the elements in the 6th group are used like function, take care to activate Prefix mode.

Now we’re coming to comments:

Adding tokens for commenting

Use Styler in the same way as you did it before. I choose deep green as color for comments. To select Allow folding of comments does exactly what it says. It allows you to fold comments together, if you want to focus on the source code only.

The final step is to define the delimitors. Select the operators and deliminators tab.

Defining the delimiters

For your convenience copy it from here:

Operators1:  “>, ; = & ( ) [ ] { } @ ! ? => .. … = < > <> + = * / <= >=</ #

Operators2:   and or not

There is no save button. So just click the cross in the upper right corner to close the dialog.

Adding styles by pushing the button Stylers is recommended… I suggest to use red color for Operators.

Now my code already has intellisense and highlights keywords. But I am still missing parameter hints and help texts.

3. Adding parameter hints and help texts by using a specific XML file

Adding parameter hints and help texts is easy for you. I already created the necessary XML file for you. At the very end of this article you find several links to downloadseveral files. I provide two files for auto completion and help texts: One in German and one in English. Download one of the following two files English auto completion file or German auto completion file from the very end of this article and put it into your APIs folder of Notepad++. On my machine I find it under …

C:\Program Files (x86)\Notepad++\plugins\APIs

Now restart your Notepad++, press ctrl+n for a new window and choose “M” as your language (as you can see in the following screenshot).

Selecting the M language in Notepad++

Now have fun writing M-statements much easier than before  ?

TAKE CARE: The name of the new language and the name of the XML file has to be the same. If you decide to use something different from M, keep this in mind. 

After each update of Power BI Desktop I will provide you with new files at the end of this article. Then just do 2 things:

  • Download the List of functions for Keywords highlightings. In Notepadd++ go to Language –> Define your language. Then go to tab Keywords Lists, delete all old Keywords from 1st group and put in the new Keywords from the List of functions for Keywords highlightings.

    Replacing old Keywords by new

  • Download the XML file again and replace the old file (in folder …plugin\APIs\) by the new. That’s it.

See you next time and keep in mind: Sharing is caring. If you liked this article, feel free to share it

Greets from Hamburg,

Lars

Download files

8th of August 2018

This update contains 2 new functions:

  • Cdm.MapToEntity()
  • Python.Execute()

List of functions for Keywords highlighting

English auto completion file

【Power Query M】Get your own Power Query Editor using Notepad++相关推荐

  1. 【论文阅读整理】TagFi: Locating Ultra-Low Power WiFi Tags Using Unmodified WiFi Infrastructure

    原文链接: https://www.researchgate.net/publication/350505530_TagFi_Locating_Ultra_Low_Power_WiFi_Tags_Us ...

  2. 【曾贤志】Power Map For Excel地图图表视频教程-曾贤志-专题视频课程

    [曾贤志]Power Map For Excel地图图表视频教程-7978人已学习 课程介绍         通过对POWER MAP的学习,可以制作跟地址相关的地图图表.让你的图表更专业.更形象. ...

  3. 【我所认知的BIOS】—Advanced Configuration and Power Interface原理(硬件部分)

    [我所认知的BIOS]->Advanced Configuration and Power Interface原理(硬件部分) LightSeed 2/24/2014 ACPI是一个内容很丰富的 ...

  4. 【悟空云课堂】第十二期:LDAP注入漏洞(CWE-90: Improper Neutralization of Special Elements used in an LDAP Query)

    关注公众号"中科天齐软件安全中心"(id:woocoom),一起涨知识! 该栏目为中科天齐全新规划的悟空云课堂,每周五下午18:00准时上线,旨在科普软件安全相关知识,助力企业有效 ...

  5. 【BIOS来电重启】Restore AC Power Loss

    为了应对实验室突然断电工作站宕机的情况,通过设置BIOS中的高级电源选项,实现来电自动开机并进入系统. .1bios电源管理 首先进入bios中的Advanced选项 随后选择APM电源管理选项 随后 ...

  6. 【番外篇】Excel:一行转多行

    [番外篇]Excel:一行转多行 国庆开始卷,更新关于Excel的小技巧:一行转多行,也是在公司遇到关于一个Excel的案例,需求如下: 原数据: 需求:要将第二列数据转换为以下一一对应的多行 操作步 ...

  7. 免费天气预报查询 API、历史天气查询 API 接口使用示例【源码可用】

    天气预报查询 API.历史天气查询 API 接口使用示例[源码可用] 福利彩蛋:没有好玩的 API 接口?上百款免费接口等你来,免费 API,免费 API 大全 一.免费天气预报查询 API 通过城市 ...

  8. ElasticSearch【有与无】【搜索引擎】【ES7】结构化查询

    目录 1.简介 1.1.请求体查询(request body  search) 空查询 1.2.结构化查询 Query DSL 空查询 查询子句 合并多子句 1.3.查询与过滤 1.4.最重要的查询过 ...

  9. Python快速进阶知识点【岗前必备技能】

    Python 课程方向: Web全栈(前端Vue,后端服务(前端App-小程序. Android/iOS 手机App. H5 响应式网站). 自动化测试(UI/功能性测试. 接口测试).开发运维(Li ...

最新文章

  1. 【驱动】GNSS驱动:gpsOneXTRA 援助技术
  2. 分布式存储系统sheepdog
  3. textarea 固定大小,滚动条,限制拖动,文字对齐
  4. C++拷贝构造函数的陷阱
  5. 第四单元用计算机写作,计算机复习题
  6. C++之使用IO库输入输出
  7. 小程序canvas转base64方法 使用upng库 亲测没问题
  8. UVA 10791 最小公倍数的和
  9. UESTC_神秘绑架案 CDOJ 881
  10. python教程视频ajax_Ajax教程
  11. 移动设备分辨率(终于弄懂了为什么移动端设计稿总是640px和750px)
  12. 机器人学领域的顶级期刊总结
  13. 51单片机最小系统电路图
  14. 银行卡卡号归属地汇总
  15. CoordinatorLayout布局和自定义Behavior
  16. 信息系统项目管理师(2022年)—— 重点内容:10大管理、5大过程组、47个过程信息汇总
  17. Neo4j3-Neo4j基础操作(中)
  18. File转MultipartFile格式
  19. 命令模式实现电视遥控器
  20. char与nchar的区别

热门文章

  1. DOCSIS 3.1 MMM--2.SYNCUCD(一)
  2. ThinkPHP3.2.3 框架实现安全数据库操作分析
  3. Android 实战制作简易天气预报
  4. [墨者安全]解析2019年国内DDOS第一季度报告
  5. office账户中有多个激活信息,删除其他多余账户信息
  6. CSS:谷歌浏览器logo网页设计
  7. SAP调用外部webservice配置
  8. excel 中任意几个数相加后等于一个数
  9. mysql 数据相加_mysql查询将两列数值相加问题
  10. 这比刷剧还爽 阿里大佬倾力打造Java1658页面试八股文,竟被开源