2015/05/24

How to combine existing worksheets using Power Query's Advanced Editor

We used to adopt VBA to combine data tables from multiple worksheets or workbooks. However, if adopt Power BI, such work could be done without any code and be more intuitive.



The way mentioned in this article, Power Query - Combine Tables, could be leveraged for most purposes. However, it still costs much time to create the data connections in advance, and those created data connections might be meaningless afterward.

After digging out the programming language, M Language, used in Power Query, we could use Power Query's advance editor to combine worksheets easier. The following example shows the way to combine 20 data tables:
let 
Source20 = Excel.CurrentWorkbook(){[Name="Table20"]}[Content],    
Source19 = Excel.CurrentWorkbook(){[Name="Table19"]}[Content],    
Source18 = Excel.CurrentWorkbook(){[Name="Table18"]}[Content],    
Source17 = Excel.CurrentWorkbook(){[Name="Table17"]}[Content],    
Source16 = Excel.CurrentWorkbook(){[Name="Table16"]}[Content],    
Source15 = Excel.CurrentWorkbook(){[Name="Table15"]}[Content],    
Source14 = Excel.CurrentWorkbook(){[Name="Table14"]}[Content],    
Source13 = Excel.CurrentWorkbook(){[Name="Table13"]}[Content],    
Source12 = Excel.CurrentWorkbook(){[Name="Table12"]}[Content],    
Source11 = Excel.CurrentWorkbook(){[Name="Table11"]}[Content],    
Source10 = Excel.CurrentWorkbook(){[Name="Table10"]}[Content],    
Source9 = Excel.CurrentWorkbook(){[Name="Table9"]}[Content],    
Source8 = Excel.CurrentWorkbook(){[Name="Table8"]}[Content],    
Source7 = Excel.CurrentWorkbook(){[Name="Table7"]}[Content],    
Source6 = Excel.CurrentWorkbook(){[Name="Table6"]}[Content],    
Source5 = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],    
Source4 = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],    
Source3 = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],    
Source2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],    
Source1 = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],    
CombineData = Table.Combine({Source20, Source19, Source18, Source17, Source16, Source15, Source14, Source13, Source12, Source11, Source10, Source9, Source8, Source7, Source6, Source5, Source4, Source3, Source2, Source1})
in   CombineData

Hope this could help you to save much time when combining data tables.


References

2014/08/01

Register URL Protocol Handlers to Invoke Specific Browsers

User Story

Need to store frequently used links in OneNote, but some links only work on some specific browser. For example, the intranet SharePoint sites would work properly with MS Internet Explorer only, and JavaScript Benchmark Sites would need to run on different browsers individually.

The following would be my link list, and would like to have the URL protocol identified easily, too. Therefore, it would be like following:
  • Intranet
    • msie:https://moss/division1/dept1
    • msie:https://moss/division1/outsourcing1
    • chrome:https://foo/projects/schedule
  • Software Testing
    • http://dromaeo.com/
      • chrome:http://dromaeo.com/
      • firefox:http://dromaeo.com/
      • msie:http://dromaeo.com/

Objecives

  • Register customized URL handlers to invoke the corresponding browser

Tasks

  • Find the way to set custom URL handlers
  • Configure the shell command to remove the custom URI scheme, and feed the target link to the specific browser

Environment

  • Windows 7 64 bits
  • Office 2010 32 bits

References

Artifact Sample:

  • Registry key for URL handler: msie://
[HKEY_CLASSES_ROOT\msie]
@="URL:MS Internet Explorer Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\msie\Shell]
[HKEY_CLASSES_ROOT\msie\Shell\Open]
[HKEY_CLASSES_ROOT\msie\Shell\Open\Command]
@=cmd /v:on /c set arg=%1 & set arg=!arg:~5! & start "C:\Program Files\Internet Explorer\iexplore.exe" !arg!