R script in Power BI returns date as Microsoft.OleDb.Date

余生长醉 提交于 2019-12-19 09:03:53

问题


I'm trying to transform a table in Power BI using the Run R Script functionality in Edit Query. The source of the table is a csv file with a column of dates of the format 2017-01-04 (yyyy-mm-dd):

2017-01-04
2017-01-03
2017-01-02
2017-01-01
2016-12-31
2016-12-30
2016-12-29
2016-12-28
2016-12-27
2016-12-26
2016-12-25
2016-12-24
2016-12-23
2016-12-22

Using Get Data, Power BI shows the same date column like this:

And after opening the Edit Query window, the very same date column still looks like this:

However, when trying to run an R sctript with the same data, the column only consists of the "values" Microsoft.OleDb.Date like this:

The R script I'm running is simply:

# 'dataset' holds the input data for this script
output <- head(dataset)

If I try to change the data type, en error is returned:

It all seems very strange to me, and I haven't found a reasonable explanation using Google.

Any suggestions?


回答1:


I already provided a solution in the comments, but I'll add a detailed suggestion here as well.

The applied steps in Power BI and the resulting date column should look like this:

Here are the details:

  1. After loading the data from the csv file, go to Edit Queries and change the data type to text:

  1. Run the R script

  2. Change the datatype back to date once the script has provided an output.



来源:https://stackoverflow.com/questions/41823277/r-script-in-power-bi-returns-date-as-microsoft-oledb-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!