Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)

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 script 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, an error is returned:

 

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

Any suggestions?

1 Answer

0 votes
by (47.2k points)
  • Steps which are applied in Power BI and the resulting date column should look like this:  

image

  • These are the details:

    • After loading the data from the CSV file, go to Edit Queries and change the data type to text

image

  • Run the R script
  • we need to change the datatype back to date once the script has provided an output.

Also, enroll in Power BI training course to become proficient in this BI tool and clear Power BI Microsoft certification exam. 

Related questions

0 votes
1 answer
asked Feb 28, 2021 in BI by dev_sk2311 (45k points)
0 votes
1 answer
asked Feb 19, 2021 in BI by dev_sk2311 (45k points)
0 votes
1 answer
asked Dec 28, 2020 in BI by Chris (11.1k points)
0 votes
1 answer
asked Nov 29, 2020 in BI by Chris (11.1k points)

Browse Categories

...