<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: R script to read query/table in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770491#M20451</link>
    <description>&lt;P&gt;Righto - you'd do something like this (assuming the destination directory exists):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;If the destination directory doesn't exist, you'll get a script error. Once you click okay, you'll get a .csv file in the specified directory, e.g.:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://mitchellpearson.com/2018/07/15/quick-tips-export-data-from-power-bi-using-r/" target="_self"&gt;Here's an article that explains in more detail&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
    <pubDate>Tue, 20 Aug 2019 05:52:27 GMT</pubDate>
    <dc:creator>dm-p</dc:creator>
    <dc:date>2019-08-20T05:52:27Z</dc:date>
    <item>
      <title>R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/769393#M20425</link>
      <description>&lt;P&gt;I am trying to read one of the query output/table using R inside script box:&amp;nbsp;&lt;/P&gt;&lt;P&gt;x &amp;lt;- table1$"Col1"&lt;/P&gt;&lt;P&gt;I get this error message:&amp;nbsp;Details: "ADO.NET: R script error. Error: object 'Table1' not found Execution halted&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone tell me how to read it?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 11:21:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/769393#M20425</guid>
      <dc:creator>neldarov</dc:creator>
      <dc:date>2019-08-19T11:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770277#M20445</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148772" data-lia-user-login="neldarov" class="lia-mention lia-mention-user"&gt;neldarov&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Are you using the R script visual? If so, the data is exposed a dataframe named &lt;FONT face="courier new,courier"&gt;dataset&lt;/FONT&gt;. Please refer to &lt;A href="https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals#create-r-visuals-in-power-bi-desktop" target="_self"&gt;step #3 in this linked article&lt;/A&gt; for reference.&lt;/P&gt;&lt;P&gt;As long as your field name is &lt;FONT face="courier new,courier"&gt;Col1&lt;/FONT&gt; then the following would work:&lt;/P&gt;&lt;PRE&gt;x &amp;lt;- dataset$"Col1"&lt;/PRE&gt;&lt;P&gt;I've tested with a recent dataset, and the editor will show any fields as part of autocomplete, e.g.: for my test dataset:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Note this code doesn't fully work in Power BI Desktop as it doesn't produce a plot (yet) but it does work if I debug in RStudio, e.g.:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Hopefully this should be all you need.&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:38:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770277#M20445</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-08-19T21:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770430#M20447</link>
      <description>&lt;P&gt;Thanks, but I am using just an R script not visuals. I need to save the table as an csv file using R script.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 04:03:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770430#M20447</guid>
      <dc:creator>neldarov</dc:creator>
      <dc:date>2019-08-20T04:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770452#M20448</link>
      <description>Hi - can you please advise where in Power BI Desktop you're running the script? Presumably Power Query if not within visuals?&lt;BR /&gt;Thanks,&lt;BR /&gt;Daniel</description>
      <pubDate>Tue, 20 Aug 2019 05:19:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770452#M20448</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-08-20T05:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770453#M20449</link>
      <description>&lt;P&gt;Yes, within query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works within visuals. However I would like to do some data analysis in R and then save it.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 05:21:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770453#M20449</guid>
      <dc:creator>neldarov</dc:creator>
      <dc:date>2019-08-20T05:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770491#M20451</link>
      <description>&lt;P&gt;Righto - you'd do something like this (assuming the destination directory exists):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;If the destination directory doesn't exist, you'll get a script error. Once you click okay, you'll get a .csv file in the specified directory, e.g.:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://mitchellpearson.com/2018/07/15/quick-tips-export-data-from-power-bi-using-r/" target="_self"&gt;Here's an article that explains in more detail&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 05:52:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770491#M20451</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-08-20T05:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770498#M20452</link>
      <description>&lt;P&gt;The article does not tell what the "dataset" is))&lt;/P&gt;&lt;P&gt;The whole point of my question is this "dataset":&lt;/P&gt;&lt;P&gt;the error here is:&amp;nbsp;Error in is.data.frame(x) : object 'dataset' not found&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to take a table or another query or another data within Power Bi&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 06:00:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770498#M20452</guid>
      <dc:creator>neldarov</dc:creator>
      <dc:date>2019-08-20T06:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770500#M20453</link>
      <description>&lt;P&gt;Can you please perhaps post an example of your query/R code? I tested the above with a query I had open in Power BI Desktop and it worked as documented.&lt;/P&gt;&lt;P&gt;The R Script transformation exposes the current step's data as an dataframe called &lt;FONT face="courier new,courier"&gt;dataset&lt;/FONT&gt;, which should be all you need, unless there is a specific transformation in your query that alters this?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 06:03:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770500#M20453</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-08-20T06:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770504#M20454</link>
      <description>&lt;P&gt;There is no code to share:&lt;/P&gt;&lt;P&gt;I have one SQL query (which is saved as a table) and I need to save it using R script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So simple, isn't it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is dataset, who creates it? I have no idea.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 06:09:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770504#M20454</guid>
      <dc:creator>neldarov</dc:creator>
      <dc:date>2019-08-20T06:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770615#M20458</link>
      <description>&lt;P&gt;It is simple :)&lt;/P&gt;&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;dataset&lt;/FONT&gt; dataframe is made available to the R Transform by Power Query.&lt;/P&gt;&lt;P&gt;I'll see if I can break down further by walking through - here's my query after I connect to a table in my database (supplying SQL in the connection dialog will produce something similar if it runs successfully):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I create a folder called test in the root directory of my hard disk, e.g.:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;In Power Query, I select&amp;nbsp;&lt;STRONG&gt;Transform&lt;/STRONG&gt; from the ribbon and then&amp;nbsp;&lt;STRONG&gt;Run R script&lt;/STRONG&gt;, e.g.:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I'm now prompted to provide my code. The pre-filled comment in the text box tells me that &lt;FONT face="courier new,courier"&gt;dataset&lt;/FONT&gt; holds the input data (results of the previous step, i.e. my table), e.g.:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I want to save the output from my SQL query as &lt;FONT face="courier new,courier"&gt;results.csv&lt;/FONT&gt; in the &lt;FONT face="courier new,courier"&gt;test&lt;/FONT&gt; subfolder I created earlier, so I add the code to do this. Because Power Query tells me I can use dataset for this, I can add this to my R code, e.g.:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;When I click&amp;nbsp;&lt;STRONG&gt;OK&lt;/STRONG&gt;, my code will run. Here's what my query looks like now:&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I can then navigate to my folder to check I have a file:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I can verify this is correct by opening it, e.g.:&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Now I know this works, I can refresh my data in Power BI Desktop any time I like and the file will be overwritten in the target location, e.g.:&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I'm hoping that this clarifies things end-to-end.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 07:29:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770615#M20458</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2019-08-20T07:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: R script to read query/table</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770719#M20459</link>
      <description>&lt;P&gt;thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 08:43:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/R-script-to-read-query-table/m-p/770719#M20459</guid>
      <dc:creator>neldarov</dc:creator>
      <dc:date>2019-08-20T08:43:33Z</dc:date>
    </item>
  </channel>
</rss>

