{"id":65,"date":"2016-04-27T21:31:26","date_gmt":"2016-04-27T21:31:26","guid":{"rendered":"http:\/\/cat5sheetstorm.com\/?p=65"},"modified":"2016-04-27T22:39:34","modified_gmt":"2016-04-27T22:39:34","slug":"power-query-salesforce-reports-2000-row-limit","status":"publish","type":"post","link":"http:\/\/cat5sheetstorm.com\/?p=65","title":{"rendered":"Power Query &#038; Salesforce Reports: 2000 row limit"},"content":{"rendered":"<p><a href=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/SFXL.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-74\" src=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/SFXL-300x105.png\" alt=\"SFXL\" width=\"300\" height=\"105\" srcset=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/SFXL-300x105.png 300w, http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/SFXL.png 640w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a>In 2014, <a href=\"https:\/\/powerbi.microsoft.com\/en-us\/blog\/announcing-power-query-support-for-salesforce-com\/\">Microsoft added a <strong>Salesforce Reports<\/strong> connector to Power Query <\/a>making it easy to pull data straight into Excel. \u00a0Awesome! Unfortunately, Salesforce limits results to\u00a02000 rows. \u00a0That&#8217;s not Microsoft&#8217;s fault. \u00a0That limit was set by Salesforce back in the Middle Ages when resources were scarce. \u00a0Or something. \u00a0I can&#8217;t explain it.\u00a0It sure does cause a lot of contortions to work around.<\/p>\n<p>Here are three\u00a0workarounds I&#8217;ve used\u00a0to exceed that 2k limit:<\/p>\n<p><strong>VBA CONTROLLING IE<\/strong>:\u00a0 Manually exporting a report in the browser is not limited.\u00a0 So I wrote a VBA macro to fire up IE, log into Salesforce, run a report,\u00a0click the\u00a0Export button, download to Excel. Ugh. It works. It&#8217;s fragile. It&#8217;s a lot of code.<\/p>\n<p><strong>APPEND method<\/strong>: This one&#8217;s MUCH easier. Create multiple copies of your report in Salesforce.com, each limited to a different &#8220;slice&#8221;\u00a0of the data. \u00a0Hopefully, each will be &lt;2000 rows and when combined you&#8217;ll have a full dataset.\u00a0In Power Query, connect to each\u00a0report, setting all but one (the primary) to\u00a0&#8220;<strong>Load To&#8230;Only Create Connection<\/strong>&#8220;. \u00a0Then in the primary query\u00a0<strong>Combine&#8230;Append<\/strong> the others and load to the worksheet. \u00a0But if any of these queries exceeds 2000 rows, you&#8217;ll be missing data and there&#8217;s no error message to warn you.<\/p>\n<p><strong>PARAMETER method<\/strong>: \u00a0You can run a\u00a0Salesforce Report in a browser with parameters in\u00a0the URL. By limiting the report to a small set of data you have a better chance of staying below 2k. \u00a0<a href=\"https:\/\/twitter.com\/CRMJav\">Javier Gonzalez <\/a>does a good job of explaining this in a blog post <a href=\"http:\/\/pragmaticforce.blogspot.com\/2011\/08\/passing-report-criteria-via-dynamic_9002.html\">here<\/a>. \u00a0Basically, you\u00a0put\u00a0filters on your report in Salesforce report ahead of time. \u00a0The operator and the value are easy to modify\u00a0with parameters later. \u00a0But the field name is not. In fact, placeholders that allow all data to pass the saved filters might be a good idea.<\/p>\n<p>Example of saved report with filters. Notice that most data is likely to pass through these filters. The unique report ID is used in the URL.<br \/>\nExample URL: https:\/\/salesforce.com\/<strong>00Oa00000XXXXX<\/strong><\/p>\n<p><a href=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/ReportBefore.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-68\" src=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/ReportBefore-300x122.png\" alt=\"ReportBefore\" width=\"300\" height=\"122\" srcset=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/ReportBefore-300x122.png 300w, http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/ReportBefore.png 354w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><\/p>\n<p>Parameters added to the\u00a0URL modify\u00a0the filters on the fly.<br \/>\n<strong>https:\/\/salesforce.com\/00Oa00000XXXXX?pn0=gt&amp;pv0=999&amp;pn1=eq&amp;pv1=New%20York&amp;pn2=eq&amp;pv2=NY<br \/>\n<a href=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/ReportAfter.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-67\" src=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/ReportAfter-300x123.png\" alt=\"ReportAfter\" width=\"300\" height=\"123\" srcset=\"http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/ReportAfter-300x123.png 300w, http:\/\/cat5sheetstorm.com\/wp-content\/uploads\/2016\/04\/ReportAfter.png 354w\" sizes=\"auto, (max-width: 300px) 85vw, 300px\" \/><\/a><\/strong>Careful: parameter numbers start with\u00a0zero<\/p>\n<p>The updated filters are temporary. \u00a0But if the user decides to<strong>\u00a0click the Save button<\/strong>\u00a0after the results appear\u00a0these\u00a0parameters become permanent. \u00a0Yikes! You&#8217;d need\u00a0to specify complete\u00a0parameters every time to avoid unexpected\u00a0results left over from a previous run. \u00a0Hmmm&#8230; I&#8217;m not loving that. \u00a0WAIT! \u00a0I have an idea. \u00a0Combine Power Query and parameters with a little VBA.<\/p>\n<p><strong>VBA PARAMETER SAVE<\/strong> method: \u00a0In Excel, I can select parameters for the report, a formula\u00a0generates the URL with those parameters all combined and correct. It&#8217;s too easy to mess these up unless its automated. \u00a0A button click runs VBA that opens IE, navigates to the\u00a0URL. When &#8220;not\u00a0IE.Busy&#8221;, VBA executes the IE Save button, closes the browser, then updates Power Query. \u00a0Voila! \u00a0It actually does work.<br \/>\nThe report is now saved with my current\u00a0parameter set, but that&#8217;s a good thing. I&#8217;ll only use it with this Excel Power Query. \u00a0Each time, parameters\u00a0are provided on the fly, the report is saved and Power Query will simply return the newly filtered results. \u00a0Still limited to\u00a02000 rows. But at least I can filter\u00a0the\u00a0report easily to limit results as needed.<\/p>\n<p>Meanwhile, we need a more robust solution.<\/p>\n<p><strong>What SALESFORCE.COM can do<\/strong>: Limiting report exports\u00a0to 2000 rows is painful\u00a0and outdated. \u00a0Given that Salesforce Reports do not allow SELECT DISTINCT (yep!) this is a huge point of frustration. \u00a0Sure I can remove duplicates in Excel easily, but I&#8217;m wasting some of my\u00a0precious 2k allotment on dupes. \u00a0I\u00a0can <span style=\"text-decoration: underline;\">manually<\/span> export the full report in the browser, but who wants to do anything manually any more.<br \/>\nVote to increase the 2000 row\u00a0limit <a href=\"https:\/\/success.salesforce.com\/ideaView?id=08730000000Dg1BAAS\">here<\/a>.<br \/>\nVote to add DISTINCT rows\u00a0<a href=\"https:\/\/success.salesforce.com\/ideaview?id=08730000000BrYLAA0\">here<\/a>\u00a0while you&#8217;re at it.<\/p>\n<p><strong>What MICROSOFT can do:<\/strong> Power Query doesn&#8217;t have any way to pass parameters to Salesforce Reports &#8211; yet. I&#8217;m hoping they\u00a0will add that capability in the\u00a0future. \u00a0I posted <a href=\"https:\/\/ideas.powerbi.com\/forums\/265200-power-bi-ideas\/suggestions\/13431762-allow-passing-of-paramaters-to-salesforce-reports\">a request for that feature here<\/a>. \u00a0Go vote for it now to increase the\u00a0chances.<\/p>\n<p>&nbsp;<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"https:\/\/twitter.com\/intent\/tweet?url=http%3A%2F%2Fcat5sheetstorm.com&amp;text=via%20Cat5Sheetstorm\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/cat5sheetstorm.com\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-48 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=Power%20Query%20%26%20Salesforce%20Reports%3A%202000%20row%20limit&amp;body=via%20Cat5Sheetstorm:%20http%3A%2F%2Fcat5sheetstorm.com\" style=\"font-size: 0px;width:48px;height:48px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"48\" height=\"48\" style=\"display: inline;width:48px;height:48px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"http:\/\/cat5sheetstorm.com\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/96x96\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>In 2014, Microsoft added a Salesforce Reports connector to Power Query making it easy to pull data straight into Excel. \u00a0Awesome! Unfortunately, Salesforce limits results to\u00a02000 rows. \u00a0That&#8217;s not Microsoft&#8217;s fault. \u00a0That limit was set by Salesforce back in the Middle Ages when resources were scarce. \u00a0Or something. \u00a0I can&#8217;t explain it.\u00a0It sure does cause &hellip; <a href=\"http:\/\/cat5sheetstorm.com\/?p=65\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Power Query &#038; Salesforce Reports: 2000 row limit&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65"}],"version-history":[{"count":7,"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":77,"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=\/wp\/v2\/posts\/65\/revisions\/77"}],"wp:attachment":[{"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cat5sheetstorm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}