Power Query is great, but there are some other options also. See Data Into Excel.

 

Excel Power Query is amazing, and powerful, and a fabulous tool for anyone serious about getting data in or out of Salesforce. 

Unfortunately if you use a OSx you are out of luck. Try installing windows in a VM just to get Power Query goodness. 

I will go through a few scenarios with examples and screen shots of how to use Power Query simply. 

There is so much you can do with Power Query, and it's related products Power Pivot and Power BI, but I am only scratching the surface.

Download

Power Query is a free download from Microsoft for Office 2010 and 2013 running on Windows 7 plus. I am running Office 2010 on Windows 7 64bit at the moment and it is working great. 

Download it here https://www.microsoft.com/en-au/download/details.aspx?id=39379

Note, it does get updated often, so if you have downloaded it previously, then re-download it again. 

Introduction

See this video

This was announced at Dreamforce '14 http://blogs.msdn.com/b/powerbi/archive/2014/10/13/announcing-power-query-support-for-salesforce-com.aspx

But wait, that's not all...

Power BI for Office 365 and Excel integrations with Salesforce. With these new integrations, customers will be able to bi-directionally load data to Salesforce and Excel to build reports, visualize information and discover new insights. Salesforce integration with Power Query for Excel is in preview now, with general availability anticipated for the first half of 2015. Power BI integration with Salesforce is anticipated for the first half of 2015. A Salesforce app for Excel is anticipated for the second half of 2015.

We are now into 2016 and no sign of this yet. I doubt we will ever see this now. I really really hate vapourware announcements at major tech conferences.

From http://www.salesforce.com/company/microsoft-faq.jsp


Oh yeah, it's now Google I/O 2016 and they have announced something similar for Google Sheets - moar vapourware! Coming in 2nd half of 2016. Yeah right, I will belive it when I see it.

Wait, where is this bi-directionality? How? Why? Do we know anything about Salesforce for Excel yet? #askforce on twitter doesn't know about it, so it will be interesting to see. Hopefully it will overcome the 2000 row limit.  

Here is a very very basic Salesforce powerpoint presentation about Power Query - if you are into that sort of thing https://success.salesforce.com/06930000003vJfc 

What I love about Power Query

Uses

Import

Here's the scenario. (This is a real scenario, but I'm using sample data to protect the innocent). 

I have a heap of data I need to import into Salesforce, and it is coming from another horrible database that has no data validation and has suffered years of neglect. The current situation is that they need to import the data into Salesforce on a weekly basis and import ALL the data because their database has no way of exporting just the new or updated records (I know, right??!?!? - People who work on these sort of databases need to reevaluate their life choices, I reckon).

The data horrors that need to be cleaned in this data set include:

Things you could also do:

So, all of this would take around 20 mins to do by hand every week. With Power Query it takes about 1 minute, and that's just to paste in the data from the downloaded spreadsheet, and run the query. 

Sample Data

I'm using the Sample Data I found for a temporal data set of employees. This is a data set that contains the full history of employee data over time. In this scenario we want to bring the employees in as contacts (yes, I know, that might not be what you would do in real life), and the old historic data will stay in the old system (again, may not happen in real life). 

The sample data - we can see that the start and end date appear for every data point. We will simplify this data to produce just a list of employees, their departments. 

Steps

Data Cleansing

VLookup 

The next step is to replace the deptno with the Salesforce ID of the lookup to the Departments object in Salesforce. 

I have a departments spreadsheet 

yes, this is made up data and they are lead ID's. 

As this is a simple vlookup we are going to use the merge function https://support.office.com/en-nz/article/Merge-queries-Power-Query-fd157620-5470-4c0f-b132-7ca2616d17f9?ui=en-US&rs=en-NZ&ad=NZ but see the articles below for a vlookup on steroids example. 

Getting ready for Salesforce

Now we need to add the data in for the salesforce import. 

Our data ready for Salesforce import

yeah, I know, the dates are not US format. I have to work out what is happening there. 

Now we can replicate that with the other data sources, or combine the data sources first to handle them all together. 

Export

Again a real scenario. My client has KPIs on number of cases answered per month. They want to do a chart to present to management overlaying KPIs with the count of Cases for the year, by quarter. How can you do that in Salesforce. It is virtually impossible (Well, there may be a big hack way of doing it, but I have not found one. The new Charts from Apsona may be able to do it http://apsona.com/pages/sfdc/apsona-charting.html). 

I ended up using http://www.klipfolio.com/ which is a brilliant brilliant, and cheap solution. But Klipfolio has a very high learning curve and is not for your average punter. 

I want to replicate this in Excel using Power Query. 

Steps

You can also do this for Objects

Technical

Getting an object from Salesforce does a REST query on the Salesforce database. 

https://na12.salesforce.com/services/data/v29.0/sobjects/Contact/describe

Notice that is uses v29.0 not v33.0 that we are (as of today) up to. 

You can enter that query into the rest explorer in workbench to see what it does. 

So technically you think you could do custom SOQL queries via the rest API. I'm sure there is a way to do it but the articles that I've seen only relate to non authenticated APIs. 

Issues

Next Steps

Please comment below as to how far you have taken Power Query. 

If you are a visual person, you might like this series of YouTube videos https://www.youtube.com/playlist?list=PLrRPvpgDmw0m3ohSvgwoHvd0KO8QsQdiK

Or if you like text, then see this series of articles http://markvsql.com/category/decathlon/

I haven't covered functions - eg simple excel functions like IF and CONCATENATE and they are really basic - exactly like excel but different syntax (TIP: Case is important!). See the article about functions below. 

Microsoft have created a whole new language for functions - the M Language - See the official formulas reference https://support.office.com/en-us/article/Power-Query-formula-categories-125024ec-873c-47b9-bdfd-b437f8716819

Then there is another whole area of coded functions that I haven't even looked into yet. 

Just search for Excel Power Query X Function to find what you want. Oh, and if you find a hyperlink function, let me know in the comments! 

And then there is the whole other layer of Power BI. That is for another page later. 

Related Articles